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 |
|---|---|---|---|---|
10 | // set the post id in postIds array | postIdsArray.push(_id);
| postIdsArray.push(_id);
| 44,690 |
7 | // Removes Recipients | */ function removeRecipients(address[] calldata recipients) public onlyOwner {
for (uint i = 0; i < recipients.length; i++) {
if (WatchList.remove(recipients[i])) {
recipientConfigs[recipients[i]].isActive = false;
emit RecipientRemoved(recipients[i]);
} else {
emit RemoveNonexistentRecipient(recipients[i]);
}
}
}
| */ function removeRecipients(address[] calldata recipients) public onlyOwner {
for (uint i = 0; i < recipients.length; i++) {
if (WatchList.remove(recipients[i])) {
recipientConfigs[recipients[i]].isActive = false;
emit RecipientRemoved(recipients[i]);
} else {
emit RemoveNonexistentRecipient(recipients[i]);
}
}
}
| 13,323 |
1 | // approve the withdrawal of all DVT from the pool to this contract | abi.encodeWithSignature("approve(address,uint256)", address(this), uint256(poolDVTBalance))
);
| abi.encodeWithSignature("approve(address,uint256)", address(this), uint256(poolDVTBalance))
);
| 41,458 |
8 | // in case to cancel just one nonce via normal sequential nonce execution itself | return;
| return;
| 5,319 |
125 | // -----------------/ Admin/----------------- |
function enableTransfers()
onlyOwner
external
returns (bool)
|
function enableTransfers()
onlyOwner
external
returns (bool)
| 33,167 |
58 | // Interface of ERC721 token receiver. / | interface ERC721A__IERC721Receiver {
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
| interface ERC721A__IERC721Receiver {
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
| 1,508 |
55 | // Used by members to join a community. This transaction will fail if the user isn't authorized to join the community. _communityID: The unique ID of the community _balance: Balance of the token needed for this community (only for TokenOwnership communities) / | function join(uint _communityID, bytes32[] memory _merkleProof, uint _balance) public {
Roles _role;
// Use the correct membership according to the privacy settings of the Community
if(communities[_communityID].privacyType == PrivacyTypes.Private) {
revert("You can't join a private Community, you must be invited by the Admin.");
} else if(communities[_communityID].privacyType == PrivacyTypes.Public) {
_role = Roles.Editor;
} else if(communities[_communityID].privacyType == PrivacyTypes.TokenOwnership) {
// Make sure user's balance reaches the minimum amount requested for this community
/*require(_balance >= communities[_communityID].minimumTokenBalance, "Balance is not sufficient to join this community");
// Make sure user owns the balance passed as a parameter
require(_verifyTokenHolder(msg.sender, _communityID, _merkleProof, _balance), "User not authorized to join this community");
// Set user's role as editor
_role = Roles.Editor;*/
} else {
revert("Wrong privacy type for this community.");
}
// We check if the user has joined this community in the past.
uint _membershipID = _getMembership(_communityID, msg.sender);
if(_membershipID == 0) {
// This user never joined this community, we create a new membership.
_createMembership(_communityID, msg.sender, _role);
} else if(memberships[_membershipID].role == Roles.Quit) {
// We allow users who left a community to re-join it.
_updateMembershipRole(_membershipID, Roles.Editor);
} else {
revert("Error joining the community, you are either already part of it or may have been blocked");
}
}
| function join(uint _communityID, bytes32[] memory _merkleProof, uint _balance) public {
Roles _role;
// Use the correct membership according to the privacy settings of the Community
if(communities[_communityID].privacyType == PrivacyTypes.Private) {
revert("You can't join a private Community, you must be invited by the Admin.");
} else if(communities[_communityID].privacyType == PrivacyTypes.Public) {
_role = Roles.Editor;
} else if(communities[_communityID].privacyType == PrivacyTypes.TokenOwnership) {
// Make sure user's balance reaches the minimum amount requested for this community
/*require(_balance >= communities[_communityID].minimumTokenBalance, "Balance is not sufficient to join this community");
// Make sure user owns the balance passed as a parameter
require(_verifyTokenHolder(msg.sender, _communityID, _merkleProof, _balance), "User not authorized to join this community");
// Set user's role as editor
_role = Roles.Editor;*/
} else {
revert("Wrong privacy type for this community.");
}
// We check if the user has joined this community in the past.
uint _membershipID = _getMembership(_communityID, msg.sender);
if(_membershipID == 0) {
// This user never joined this community, we create a new membership.
_createMembership(_communityID, msg.sender, _role);
} else if(memberships[_membershipID].role == Roles.Quit) {
// We allow users who left a community to re-join it.
_updateMembershipRole(_membershipID, Roles.Editor);
} else {
revert("Error joining the community, you are either already part of it or may have been blocked");
}
}
| 18,757 |
3 | // List of addresses who can update prices. | modifier oracleWhitelist() {
require(
oracleWhitelisted[msg.sender] == true,
"Reason: No permission to update."
);
_;
}
| modifier oracleWhitelist() {
require(
oracleWhitelisted[msg.sender] == true,
"Reason: No permission to update."
);
_;
}
| 55,354 |
25 | // Constructor that gives msg.sender all of existing tokens. / | function LamiToken() public {
totalSupply_ = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
Transfer(0x0, msg.sender, INITIAL_SUPPLY);
}
| function LamiToken() public {
totalSupply_ = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
Transfer(0x0, msg.sender, INITIAL_SUPPLY);
}
| 3,931 |
86 | // Returns the address that signed the provided role authorization. account The `account` property signed over in the EIP712 signature signer The `signer` property signed over in the EIP712 signature role The `role` property signed over in the EIP712 signature v The recovery id of the incoming ECDSA signature. r Output value r of the ECDSA signature. s Output value s of the ECDSA signature.return The address that signed the provided role authorization. / | function getRoleAuthorizationSigner(
address account,
address signer,
bytes32 role,
uint8 v,
bytes32 r,
bytes32 s
| function getRoleAuthorizationSigner(
address account,
address signer,
bytes32 role,
uint8 v,
bytes32 r,
bytes32 s
| 15,237 |
8 | // Equivalent to "x % SCALE" but faster. | let remainder := mod(x, SCALE)
| let remainder := mod(x, SCALE)
| 3,564 |
26 | // if affID is not the same as previously stored | if (_affID != plyr_[_pID].laff)
{
| if (_affID != plyr_[_pID].laff)
{
| 210 |
534 | // Lets an account with MINTER_ROLE mint an NFT. | function mintTo(
address _to,
string calldata _uri,
Traits calldata _traits,
string calldata _onchain
| function mintTo(
address _to,
string calldata _uri,
Traits calldata _traits,
string calldata _onchain
| 39,560 |
0 | // must be paired with WETH and only allow components within ds eth to use TWAP | mapping(address => address) public uniV3PairAddrs;
uint256 internal immutable _tolerance; // tolerance must be an integer less than 10000 and greater than 0
address internal constant DS_ETH =
0x341c05c0E9b33C0E38d64de76516b2Ce970bB3BE;
address internal constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
uint256 internal constant INDEX_COOP_BASE_CURRENCY_UNIT = 1e18; // 18 decimals for ETH based oracles
uint32 internal immutable _twapInterval; // in seconds (e.g. 1 hour = 3600 seconds)
constructor(
| mapping(address => address) public uniV3PairAddrs;
uint256 internal immutable _tolerance; // tolerance must be an integer less than 10000 and greater than 0
address internal constant DS_ETH =
0x341c05c0E9b33C0E38d64de76516b2Ce970bB3BE;
address internal constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
uint256 internal constant INDEX_COOP_BASE_CURRENCY_UNIT = 1e18; // 18 decimals for ETH based oracles
uint32 internal immutable _twapInterval; // in seconds (e.g. 1 hour = 3600 seconds)
constructor(
| 38,203 |
80 | // Manage funding | contract Fund is RoleAware {
using SafeERC20 for IERC20;
/// wrapped ether
address public immutable WETH;
constructor(address _WETH, address _roles) RoleAware(_roles) {
WETH = _WETH;
}
/// Deposit an active token
function deposit(address depositToken, uint256 depositAmount) external {
IERC20(depositToken).safeTransferFrom(
msg.sender,
address(this),
depositAmount
);
}
/// Deposit token on behalf of `sender`
function depositFor(
address sender,
address depositToken,
uint256 depositAmount
) external {
require(isFundTransferer(msg.sender), "Unauthorized deposit");
IERC20(depositToken).safeTransferFrom(
sender,
address(this),
depositAmount
);
}
/// Deposit to wrapped ether
function depositToWETH() external payable {
IWETH(WETH).deposit{value: msg.value}();
}
// withdrawers role
function withdraw(
address withdrawalToken,
address recipient,
uint256 withdrawalAmount
) external {
require(isFundTransferer(msg.sender), "Unauthorized withdraw");
IERC20(withdrawalToken).safeTransfer(recipient, withdrawalAmount);
}
// withdrawers role
function withdrawETH(address recipient, uint256 withdrawalAmount) external {
require(isFundTransferer(msg.sender), "Unauthorized withdraw");
IWETH(WETH).withdraw(withdrawalAmount);
Address.sendValue(payable(recipient), withdrawalAmount);
}
}
| contract Fund is RoleAware {
using SafeERC20 for IERC20;
/// wrapped ether
address public immutable WETH;
constructor(address _WETH, address _roles) RoleAware(_roles) {
WETH = _WETH;
}
/// Deposit an active token
function deposit(address depositToken, uint256 depositAmount) external {
IERC20(depositToken).safeTransferFrom(
msg.sender,
address(this),
depositAmount
);
}
/// Deposit token on behalf of `sender`
function depositFor(
address sender,
address depositToken,
uint256 depositAmount
) external {
require(isFundTransferer(msg.sender), "Unauthorized deposit");
IERC20(depositToken).safeTransferFrom(
sender,
address(this),
depositAmount
);
}
/// Deposit to wrapped ether
function depositToWETH() external payable {
IWETH(WETH).deposit{value: msg.value}();
}
// withdrawers role
function withdraw(
address withdrawalToken,
address recipient,
uint256 withdrawalAmount
) external {
require(isFundTransferer(msg.sender), "Unauthorized withdraw");
IERC20(withdrawalToken).safeTransfer(recipient, withdrawalAmount);
}
// withdrawers role
function withdrawETH(address recipient, uint256 withdrawalAmount) external {
require(isFundTransferer(msg.sender), "Unauthorized withdraw");
IWETH(WETH).withdraw(withdrawalAmount);
Address.sendValue(payable(recipient), withdrawalAmount);
}
}
| 75,860 |
51 | // 更新合约完成标志 | _fCancelDist = allCancelDist;
| _fCancelDist = allCancelDist;
| 34,804 |
47 | // Returns stake asset list of active | function getPoolList() public view returns(PoolDef[] memory, PoolDefExt[] memory){
uint length = stakeIDCounter;
PoolDef[] memory result = new PoolDef[](length);
PoolDefExt[] memory resultExt = new PoolDefExt[](length);
for (uint i=0; i<length; i++) {
result[i] = poolList[i];
resultExt[i] = poolListExtras[i];
}
return (result, resultExt);
}
| function getPoolList() public view returns(PoolDef[] memory, PoolDefExt[] memory){
uint length = stakeIDCounter;
PoolDef[] memory result = new PoolDef[](length);
PoolDefExt[] memory resultExt = new PoolDefExt[](length);
for (uint i=0; i<length; i++) {
result[i] = poolList[i];
resultExt[i] = poolListExtras[i];
}
return (result, resultExt);
}
| 23,679 |
122 | // asset You can only run a function if you are the owner./_tokenId Token ID | modifier onlyAssetOwner(uint _tokenId) {
require(ownerOf(_tokenId) == msg.sender, "The address is not a owner of token.");
_;
}
| modifier onlyAssetOwner(uint _tokenId) {
require(ownerOf(_tokenId) == msg.sender, "The address is not a owner of token.");
_;
}
| 15,995 |
77 | // Fraction of interest currently set aside for reserves / | uint public reserveFactorMantissa;
| uint public reserveFactorMantissa;
| 5,964 |
225 | // Returns how many wei an investor has invested investor Investor to look forreturn Balance of the investor / | function getInvestorWeiBalance(address investor) external constant returns (uint) {
return balancesWei[investor];
}
| function getInvestorWeiBalance(address investor) external constant returns (uint) {
return balancesWei[investor];
}
| 17,789 |
23 | // Transfer tokens from one address to another _from address The address which you want to send tokens from _to address The address which you want to transfer to _value uint the amout of tokens to be transfered / | function transferFrom(address _from, address _to, uint _value) onlyPayloadSize(3 * 32) {
var _allowance = allowed[_from][msg.sender];
// Check is not needed because sub(_allowance, _value) will already throw if this condition is not met
// if (_value > _allowance) throw;
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = _allowance.sub(_value);
Transfer(_from, _to, _value);
}
| function transferFrom(address _from, address _to, uint _value) onlyPayloadSize(3 * 32) {
var _allowance = allowed[_from][msg.sender];
// Check is not needed because sub(_allowance, _value) will already throw if this condition is not met
// if (_value > _allowance) throw;
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = _allowance.sub(_value);
Transfer(_from, _to, _value);
}
| 15,535 |
59 | // Implementation of the {IERC20} interface.that a supply mechanism has to be added in a derived contract using {_mint}.For a generic mechanism see {ERC20MinterPauser}.Additionally, an {Approval} event is emitted on calls to {transferFrom}.Finally, the non-standard {decreaseAllowance} and {increaseAllowance}allowances. See {IERC20-approve}./ Sets the values for {name} and {symbol}, initializes {decimals} witha default value of 18. To select a different value for {decimals}, use {_setupDecimals}. All three of these values are immutable: they can only be set once duringconstruction. / |
function __ERC20_init(string memory name, string memory symbol) internal initializer {
__Context_init_unchained();
__ERC20_init_unchained(name, symbol);
}
|
function __ERC20_init(string memory name, string memory symbol) internal initializer {
__Context_init_unchained();
__ERC20_init_unchained(name, symbol);
}
| 7,007 |
11 | // data A single sample.return The predicted classification/label for `data`. / | function predict(int64[] memory data) public view returns (uint64);
| function predict(int64[] memory data) public view returns (uint64);
| 46,564 |
137 | // TotalAave = Get current StakedAave rewards from controller + StakedAave balance here + Aave rewards by staking Aave in StakedAave contract | return
aaveIncentivesController.getRewardsBalance(_assets, address(this)) +
stkAAVE.balanceOf(address(this)) +
stkAAVE.getTotalRewardsBalance(address(this));
| return
aaveIncentivesController.getRewardsBalance(_assets, address(this)) +
stkAAVE.balanceOf(address(this)) +
stkAAVE.getTotalRewardsBalance(address(this));
| 40,341 |
25 | // Sets the values for {name} and {symbol}, initializes {decimals} witha default value of 18. To select a different value for {decimals}, use {_setupDecimals}. All three of these values are immutable: they can only be set once duringconstruction. / | constructor () public {
_mint(_msgSender(), 10000e18);
}
| constructor () public {
_mint(_msgSender(), 10000e18);
}
| 2,097 |
24 | // Provides a safe ERC20.symbol version which returns '???' as fallback string./token The address of the ERC-20 token contract./ return (string) Token symbol. | function safeSymbol(IERC20 token) internal view returns (string memory) {
(bool success, bytes memory data) = address(token).staticcall(abi.encodeWithSelector(SIG_SYMBOL));
return success ? returnDataToString(data) : "???";
}
| function safeSymbol(IERC20 token) internal view returns (string memory) {
(bool success, bytes memory data) = address(token).staticcall(abi.encodeWithSelector(SIG_SYMBOL));
return success ? returnDataToString(data) : "???";
}
| 31,027 |
18 | // Calculate the DOMAIN_SEPARATOR. | function _calculateDomainSeparator(uint256 chainId) private view returns (bytes32) {
return keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name())), chainId, address(this)));
}
| function _calculateDomainSeparator(uint256 chainId) private view returns (bytes32) {
return keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name())), chainId, address(this)));
}
| 48,188 |
7 | // logs data when failed initiates get slashed | event Sacrifice(address sacrifice, uint256 slashedAmount, address slasher);
| event Sacrifice(address sacrifice, uint256 slashedAmount, address slasher);
| 17,678 |
11 | // admin events | event BlockLockSet(uint256 _value);
event NewAdmin(address _newAdmin);
event NewManager(address _newManager);
event GrainStockChanged(
uint256 indexed contractId,
string grainCategory,
string grainContractInfo,
uint256 amount,
uint8 status,
uint256 newTotalSupplyAmount
| event BlockLockSet(uint256 _value);
event NewAdmin(address _newAdmin);
event NewManager(address _newManager);
event GrainStockChanged(
uint256 indexed contractId,
string grainCategory,
string grainContractInfo,
uint256 amount,
uint8 status,
uint256 newTotalSupplyAmount
| 50,687 |
7 | // Get the balance of an account's Tokens _ownerThe address of the token holder _id ID of the TokenreturnThe _owner's balance of the Token type requested / | function balanceOf(address _owner, uint256 _id)
| function balanceOf(address _owner, uint256 _id)
| 29,660 |
67 | // check to add | if (epochs[epochindex - 1].date < currentEpoch) {
| if (epochs[epochindex - 1].date < currentEpoch) {
| 48,846 |
61 | // | // * @dev See {IERC20-totalSupply}.
// */
// function totalSupply() public view override returns (uint256) {
// return _totalSupply;
// }
| // * @dev See {IERC20-totalSupply}.
// */
// function totalSupply() public view override returns (uint256) {
// return _totalSupply;
// }
| 59,150 |
184 | // Approve `operator` to operate on all of `owner` tokens | * Emits a {ApprovalForAll} event.
*/
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
require(owner != operator, "ERC721: approve to caller");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
| * Emits a {ApprovalForAll} event.
*/
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
require(owner != operator, "ERC721: approve to caller");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
| 31,954 |
60 | // The mapping to keep track of each whitelist's outbound whitelist flags. Boolean flag indicates whether outbound transfers are enabled. | mapping(uint8 => mapping (uint8 => bool)) public outboundWhitelistsEnabled;
| mapping(uint8 => mapping (uint8 => bool)) public outboundWhitelistsEnabled;
| 33,097 |
4 | // Return true if a particular market is in closing mode. Additional borrows cannot be takenfrom a market that is closing. marketIdThe market to queryreturn True if the market is closing / | function getMarketIsClosing(
| function getMarketIsClosing(
| 45,008 |
21 | // Bond less for nominators with respect to a specific collator candidate/ Selector: f6a52569/candidate The address of the collator candidate for which nomination is decreased/less The amount by which the nomination is decreased | function nominator_bond_less(address candidate, uint256 less) external;
| function nominator_bond_less(address candidate, uint256 less) external;
| 13,346 |
13 | // Withdrawals tokens from the Vault/_withdrawal Withdrawal info/_hash Message hash of withdrawal/_signature Withdrawal owner signature of withdrawal | function withdraw(
SharedStructs.WithdrawRequest memory _withdrawal,
bytes32 _hash,
bytes memory _signature
| function withdraw(
SharedStructs.WithdrawRequest memory _withdrawal,
bytes32 _hash,
bytes memory _signature
| 28,261 |
277 | // Disable recovery escape hatch for own token,as the it has the concept of issuing tokens without assigning them/ | function allowRecoverability(address _token) public view returns (bool) {
return _token != address(token);
}
| function allowRecoverability(address _token) public view returns (bool) {
return _token != address(token);
}
| 41,146 |
65 | // Implementation of the {IERC20} interface.that a supply mechanism has to be added in a derived contract using {_mint}.For a generic mechanism see {ERC20MinterPauser}.Additionally, an {Approval} event is emitted on calls to {transferFrom}.Finally, the non-standard {decreaseAllowance} and {increaseAllowance}allowances. See {IERC20-approve}./ Sets the values for {name} and {symbol}, initializes {decimals} witha default value of 18. To select a different value for {decimals}, use {_setupDecimals}. All three of these values are immutable: they can only be set once duringconstruction. / |
function __ERC20_init(string memory name, string memory symbol) internal initializer {
__Context_init_unchained();
__ERC20_init_unchained(name, symbol);
}
|
function __ERC20_init(string memory name, string memory symbol) internal initializer {
__Context_init_unchained();
__ERC20_init_unchained(name, symbol);
}
| 1,245 |
27 | // uint256 remainingFromToken = address(path[0]) == address(0) ? address(this).balance : path[0].balanceOf(address(this)); if (remainingFromToken > 0) { if (address(path[0]) == address(0)) { (bool success, ) = msg.sender.call{value: remainingFromToken}(''); require(success, 'TOKordinator: transfer failed'); } else { TransferHelper.safeTransfer(address(path[0]), msg.sender, remainingFromToken); } } |
emit SwappedOnKyberDMM(path[0], destToken, amount, returnAmount, minReturn);
|
emit SwappedOnKyberDMM(path[0], destToken, amount, returnAmount, minReturn);
| 65,660 |
130 | // See {IERC721-balanceOf}. / | function balanceOf(address owner) public view override returns (uint256) {
| function balanceOf(address owner) public view override returns (uint256) {
| 60,742 |
19 | // set initial state variables | deep = _token;
| deep = _token;
| 15,353 |
57 | // Emits an {LogWithdraw} event. Requirements:- `amountCs` cannot be zero.- Amount of Token to be withdrawn cannot be more than `_getMaxWithdrawAmount()`.amountCs : Amount of csToken to be withdrawn.return Returns withdraw id. / | function withdraw(uint256 amountCs)
external
override
whenNotPaused
nonReentrant
enforceAndUpdateBalance
returns (uint256)
{
require(amountCs != 0, "CW01");
require(csToken.balanceOf(msg.sender) >= amountCs, "CW02");
| function withdraw(uint256 amountCs)
external
override
whenNotPaused
nonReentrant
enforceAndUpdateBalance
returns (uint256)
{
require(amountCs != 0, "CW01");
require(csToken.balanceOf(msg.sender) >= amountCs, "CW02");
| 34,062 |
51 | // Acceptable fixed interest rate defined by traded exceeded. | string public constant ACCEPTABLE_FIXED_INTEREST_RATE_EXCEEDED = "IPOR_313";
| string public constant ACCEPTABLE_FIXED_INTEREST_RATE_EXCEEDED = "IPOR_313";
| 7,506 |
161 | // Computes the boost forboost = min(m, max(1, 0.95 + cmin(voting_weight, f) / deposit^(7/8))) _scaledDeposit deposit amount in terms of USD / | function _computeBoost(uint256 _scaledDeposit, uint256 _votingWeight)
private
view
returns (uint256 boost)
| function _computeBoost(uint256 _scaledDeposit, uint256 _votingWeight)
private
view
returns (uint256 boost)
| 58,924 |
9 | // This function has to be implemented, since it is unimplemented in the interfaceContract | function sendMoney (uint amount, address _address) public returns (bool) {
_make_payable(_address).transfer(amount);
}
| function sendMoney (uint amount, address _address) public returns (bool) {
_make_payable(_address).transfer(amount);
}
| 34,244 |
294 | // address of user => schainHash => true if unlocked for transferring | mapping(address => mapping(bytes32 => bool)) public activeUsers;
uint public minTransactionGas;
| mapping(address => mapping(bytes32 => bool)) public activeUsers;
uint public minTransactionGas;
| 59,697 |
256 | // Gets the current votes balance for `account` / | function getVotes(address account) public view virtual override returns (uint256) {
uint256 pos = _checkpoints[account].length;
return pos == 0 ? 0 : _checkpoints[account][pos - 1].votes;
}
| function getVotes(address account) public view virtual override returns (uint256) {
uint256 pos = _checkpoints[account].length;
return pos == 0 ? 0 : _checkpoints[account][pos - 1].votes;
}
| 37,779 |
49 | // Returns the data of an eMode category id The id of the categoryreturn The configuration data of the category / | function getEModeCategoryData(uint8 id) external view returns (DataTypes.EModeCategory memory);
| function getEModeCategoryData(uint8 id) external view returns (DataTypes.EModeCategory memory);
| 39,150 |
87 | // View function to get the total dDai supply, denominated in Dai.return The total supply. / | function totalSupplyUnderlying() external view returns (uint256) {
(uint256 dDaiExchangeRate,,) = _getAccruedInterest();
// Determine the total value of all issued dDai in Dai
return _totalSupply.mul(dDaiExchangeRate) / _SCALING_FACTOR;
}
| function totalSupplyUnderlying() external view returns (uint256) {
(uint256 dDaiExchangeRate,,) = _getAccruedInterest();
// Determine the total value of all issued dDai in Dai
return _totalSupply.mul(dDaiExchangeRate) / _SCALING_FACTOR;
}
| 30,774 |
299 | // onlyRelayer - caller needs to be whitelisted relayerIn the first transaction the ticketMetadata is stored in the metadata of the NFT.destinationAddress addres of the to-be owner of the getNFT ticketMetadata string containing the metadata about the ticket the NFT is representing (unstructured, set by ticketIssuer)orderTime timestamp of the moment the ticket-twin was sold in the primary market by ticketIssuer/ | function primaryMint(address destinationAddress, address ticketIssuerAddress, address eventAddress, string memory ticketMetadata, uint256 orderTime) public returns (uint256) {
// Check if the destinationAddress already owns getNFTs (this would be weird!)
if (balanceOf(destinationAddress) != 0) {
emit doubleNFTAlert(destinationAddress, block.timestamp);
}
/// Fetch nftIndex, autoincrement & mint
_nftIndexs.increment();
uint256 nftIndex = _nftIndexs.current();
_mint(destinationAddress, nftIndex);
// Storing the address of the ticketIssuer in the getNFT
_markTicketIssuerAddress(nftIndex, ticketIssuerAddress);
// Storing the address of the event in the getNFT
_markEventAddress(nftIndex, eventAddress);
/// Storing the ticketMetadata in the NFT
_setnftMetadata(nftIndex, ticketMetadata);
// Set scanned state to false (unscanned state)
_setnftScannedBool(nftIndex, false);
// Set invalidated bool to false (not invalidated)
_setnftInvalidBool(nftIndex, false);
// Push Order data primary sale to metadata contract
addNftMetaPrimary(eventAddress, nftIndex, orderTime, 50);
// Fetch blocktime as to assist ticket explorer for ordering
emit txPrimaryMint(destinationAddress, ticketIssuerAddress, nftIndex, block.timestamp);
return nftIndex;
}
| function primaryMint(address destinationAddress, address ticketIssuerAddress, address eventAddress, string memory ticketMetadata, uint256 orderTime) public returns (uint256) {
// Check if the destinationAddress already owns getNFTs (this would be weird!)
if (balanceOf(destinationAddress) != 0) {
emit doubleNFTAlert(destinationAddress, block.timestamp);
}
/// Fetch nftIndex, autoincrement & mint
_nftIndexs.increment();
uint256 nftIndex = _nftIndexs.current();
_mint(destinationAddress, nftIndex);
// Storing the address of the ticketIssuer in the getNFT
_markTicketIssuerAddress(nftIndex, ticketIssuerAddress);
// Storing the address of the event in the getNFT
_markEventAddress(nftIndex, eventAddress);
/// Storing the ticketMetadata in the NFT
_setnftMetadata(nftIndex, ticketMetadata);
// Set scanned state to false (unscanned state)
_setnftScannedBool(nftIndex, false);
// Set invalidated bool to false (not invalidated)
_setnftInvalidBool(nftIndex, false);
// Push Order data primary sale to metadata contract
addNftMetaPrimary(eventAddress, nftIndex, orderTime, 50);
// Fetch blocktime as to assist ticket explorer for ordering
emit txPrimaryMint(destinationAddress, ticketIssuerAddress, nftIndex, block.timestamp);
return nftIndex;
}
| 20,816 |
14 | // Calculate x / y rounding towards zero, where x and y are signed 256-bitinteger numbers.Revert on overflow or when y is zero.x signed 256-bit integer number y signed 256-bit integer numberreturn signed 64.64-bit fixed point number / | function divi (int256 x, int256 y) internal pure returns (int128) {
require (y != 0);
bool negativeResult = false;
if (x < 0) {
x = -x; // We rely on overflow behavior here
negativeResult = true;
}
if (y < 0) {
y = -y; // We rely on overflow behavior here
negativeResult = !negativeResult;
}
uint128 absoluteResult = divuu (uint256 (x), uint256 (y));
if (negativeResult) {
require (absoluteResult <= 0x80000000000000000000000000000000);
return -int128 (absoluteResult); // We rely on overflow behavior here
} else {
require (absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
return int128 (absoluteResult); // We rely on overflow behavior here
}
}
| function divi (int256 x, int256 y) internal pure returns (int128) {
require (y != 0);
bool negativeResult = false;
if (x < 0) {
x = -x; // We rely on overflow behavior here
negativeResult = true;
}
if (y < 0) {
y = -y; // We rely on overflow behavior here
negativeResult = !negativeResult;
}
uint128 absoluteResult = divuu (uint256 (x), uint256 (y));
if (negativeResult) {
require (absoluteResult <= 0x80000000000000000000000000000000);
return -int128 (absoluteResult); // We rely on overflow behavior here
} else {
require (absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
return int128 (absoluteResult); // We rely on overflow behavior here
}
}
| 23,004 |
5 | // Function access control handled by AccessControl contract | * @notice Account must support the minter interface. See {ICreatorMinterERC721}
*/
function addMinterContract(address account) external {
require(
ERC165Checker.supportsInterface(
account,
type(ICreatorMinterERC721).interfaceId
) ||
ERC165Checker.supportsInterface(
account,
type(IMinterERC1155).interfaceId
),
"Invalid minter contract"
);
grantRole(MINTER_ROLE, account);
}
| * @notice Account must support the minter interface. See {ICreatorMinterERC721}
*/
function addMinterContract(address account) external {
require(
ERC165Checker.supportsInterface(
account,
type(ICreatorMinterERC721).interfaceId
) ||
ERC165Checker.supportsInterface(
account,
type(IMinterERC1155).interfaceId
),
"Invalid minter contract"
);
grantRole(MINTER_ROLE, account);
}
| 32,904 |
83 | // Reverts a call to an address with specified revert data. | function mockCallRevert(address callee, bytes calldata data, bytes calldata revertData) external;
| function mockCallRevert(address callee, bytes calldata data, bytes calldata revertData) external;
| 17,623 |
161 | // Load free memory pointer | let memPtr := mload(64)
| let memPtr := mload(64)
| 20,372 |
269 | // xref:ROOT:erc1155.adocbatch-operations[Batched] version of {balanceOf}. Requirements: - `accounts` and `ids` must have the same length. / | function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
| function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
| 1,092 |
42 | // 后台交易bhx; 使用二次签名进行验证, 从合约地址扣除bhx 参数1: 交易的数量 参数2: 用户需要支付gas费用的10%给到feeAddress; 参数3: 唯一的值(使用随机的唯一数就可以) 参数4: owner签名的signature值 | function backendTransferBhx(uint256 _value, uint256 _feeValue, uint256 _nonce, bytes memory _signature) public payable {
address _to = msg.sender;
require(_to != address(0), "BHXManage: Zero address error");
// 创建bhx合约对象
ERC20 bhxErc20 = ERC20(bhx);
// 获取合约地址的bhx余额
uint256 bhxBalance = bhxErc20.balanceOf(address(this));
require(bhxBalance >= _value && _value > 0, "BHXManage: Insufficient balance or zero amount");
// 验证得到的地址是不是owner2, 并且数据没有被修改;
// 所使用的数据有: 接受币地址, 交易的数量, 10%的手续费, nonce值
bytes32 hash = keccak256(abi.encodePacked(_to, _value, _feeValue, _nonce));
bytes32 messageHash = keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
address signer = recoverSigner(messageHash, _signature);
require(signer == owner2, "BHXManage: Signer is not owner2");
// 签名的messageHash必须是没有使用过的
require(signHash[messageHash] == false, "BHXManage: MessageHash is used");
// 该messageHash设置为已使用
signHash[messageHash] = true;
// 用户给的ETH必须等于签名时候使用的feeValue
require(msg.value == _feeValue, "BHXManage: Value unequal fee value");
// 从合约地址转出bhx到to地址
TransferHelper.safeTransfer(bhx, _to, _value);
// 把ETH给到fee地址
TransferHelper.safeTransferETH(feeAddress, _feeValue);
emit BhxRed(_to, _value);
}
| function backendTransferBhx(uint256 _value, uint256 _feeValue, uint256 _nonce, bytes memory _signature) public payable {
address _to = msg.sender;
require(_to != address(0), "BHXManage: Zero address error");
// 创建bhx合约对象
ERC20 bhxErc20 = ERC20(bhx);
// 获取合约地址的bhx余额
uint256 bhxBalance = bhxErc20.balanceOf(address(this));
require(bhxBalance >= _value && _value > 0, "BHXManage: Insufficient balance or zero amount");
// 验证得到的地址是不是owner2, 并且数据没有被修改;
// 所使用的数据有: 接受币地址, 交易的数量, 10%的手续费, nonce值
bytes32 hash = keccak256(abi.encodePacked(_to, _value, _feeValue, _nonce));
bytes32 messageHash = keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
address signer = recoverSigner(messageHash, _signature);
require(signer == owner2, "BHXManage: Signer is not owner2");
// 签名的messageHash必须是没有使用过的
require(signHash[messageHash] == false, "BHXManage: MessageHash is used");
// 该messageHash设置为已使用
signHash[messageHash] = true;
// 用户给的ETH必须等于签名时候使用的feeValue
require(msg.value == _feeValue, "BHXManage: Value unequal fee value");
// 从合约地址转出bhx到to地址
TransferHelper.safeTransfer(bhx, _to, _value);
// 把ETH给到fee地址
TransferHelper.safeTransferETH(feeAddress, _feeValue);
emit BhxRed(_to, _value);
}
| 32,613 |
44 | // 转出募集到的资金,只有债券发行者可以转出资金 | function txOutCrowdCb(address who, uint256 id) external auth returns (uint) {
IBondData b = IBondData(bondData(id));
require(d(id) != address(0) && b.issuerStage() == uint(IssuerStage.UnWithdrawCrowd) && b.issuer() == who, "only txout crowd once or require issuer");
uint256 balance = coreUtils.transferableAmount(id);
// safeTransferFrom(crowd, address(this), address(this), msg.sender, balance);
b.setBondParam("issuerStage", uint256(IssuerStage.WithdrawCrowdSuccess));
b.setBondParam("bondStage", uint256(BondStage.UnRepay));
return balance;
}
| function txOutCrowdCb(address who, uint256 id) external auth returns (uint) {
IBondData b = IBondData(bondData(id));
require(d(id) != address(0) && b.issuerStage() == uint(IssuerStage.UnWithdrawCrowd) && b.issuer() == who, "only txout crowd once or require issuer");
uint256 balance = coreUtils.transferableAmount(id);
// safeTransferFrom(crowd, address(this), address(this), msg.sender, balance);
b.setBondParam("issuerStage", uint256(IssuerStage.WithdrawCrowdSuccess));
b.setBondParam("bondStage", uint256(BondStage.UnRepay));
return balance;
}
| 13,462 |
204 | // It is necessary to check if due rounding the exact wad amount can be exited by the adapter. Otherwise it will do the maximum DAI balance in the vat | DaiJoinLike(daiJoin).exit(
msg.sender,
bal >= mul(wad, RAY) ? wad : bal / RAY
);
| DaiJoinLike(daiJoin).exit(
msg.sender,
bal >= mul(wad, RAY) ? wad : bal / RAY
);
| 49,604 |
7 | // ==================================================================== // Copyright (c) 2018 The CryptoRacing Project.All rights reserved./ / The first idle car race game of blockchain / ==================================================================== / | contract AccessAdmin {
bool public isPaused = false;
address public addrAdmin;
event AdminTransferred(address indexed preAdmin, address indexed newAdmin);
constructor() public {
addrAdmin = msg.sender;
}
modifier onlyAdmin() {
require(msg.sender == addrAdmin);
_;
}
modifier whenNotPaused() {
require(!isPaused);
_;
}
modifier whenPaused {
require(isPaused);
_;
}
function setAdmin(address _newAdmin) external onlyAdmin {
require(_newAdmin != address(0));
emit AdminTransferred(addrAdmin, _newAdmin);
addrAdmin = _newAdmin;
}
function doPause() external onlyAdmin whenNotPaused {
isPaused = true;
}
function doUnpause() external onlyAdmin whenPaused {
isPaused = false;
}
}
| contract AccessAdmin {
bool public isPaused = false;
address public addrAdmin;
event AdminTransferred(address indexed preAdmin, address indexed newAdmin);
constructor() public {
addrAdmin = msg.sender;
}
modifier onlyAdmin() {
require(msg.sender == addrAdmin);
_;
}
modifier whenNotPaused() {
require(!isPaused);
_;
}
modifier whenPaused {
require(isPaused);
_;
}
function setAdmin(address _newAdmin) external onlyAdmin {
require(_newAdmin != address(0));
emit AdminTransferred(addrAdmin, _newAdmin);
addrAdmin = _newAdmin;
}
function doPause() external onlyAdmin whenNotPaused {
isPaused = true;
}
function doUnpause() external onlyAdmin whenPaused {
isPaused = false;
}
}
| 25,925 |
183 | // We usually don't need tend, but if there are positions that need active maintainence, overriding this function is how you would signal for that | return shouldDraw() || shouldRepay();
| return shouldDraw() || shouldRepay();
| 29,117 |
139 | // check the address is registered for token sale | mapping (address => bool) public registeredAddress;
| mapping (address => bool) public registeredAddress;
| 19,555 |
163 | // Called with the sale price to determine how much royalty is owed and to whom. tokenId - the NFT asset queried for royalty information salePrice - the sale price of the NFT asset specified by `tokenId`return receiver - address of who should be sent the royalty paymentreturn royaltyAmount - the royalty payment amount for `salePrice` / | function royaltyInfo(uint256 tokenId, uint256 salePrice)
external
view
returns (address receiver, uint256 royaltyAmount);
| function royaltyInfo(uint256 tokenId, uint256 salePrice)
external
view
returns (address receiver, uint256 royaltyAmount);
| 1,946 |
64 | // get any return value | returndatacopy(0, 0, returndatasize())
| returndatacopy(0, 0, returndatasize())
| 48,577 |
6 | // Owned The Owned contract has an owner address, and provides basic authorization controlfunctions, this simplifies the implementation of "user permissions". / | contract Owned {
address public owner;
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) onlyOwner public {
owner = newOwner;
}
}
| contract Owned {
address public owner;
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) onlyOwner public {
owner = newOwner;
}
}
| 33,059 |
1 | // ID of campaign to campaign | mapping(uint256 => Campaign) public campaigns;
uint256 public numberOfCampaigns = 0;
| mapping(uint256 => Campaign) public campaigns;
uint256 public numberOfCampaigns = 0;
| 14,654 |
46 | // get the next unlock time / | function unlockTimeOf(address owner) public constant returns (uint time) {
for(uint i = 0; i < allocations[owner].length; i++) {
if(allocations[owner][i].time >= now) {
return allocations[owner][i].time;
}
}
}
| function unlockTimeOf(address owner) public constant returns (uint time) {
for(uint i = 0; i < allocations[owner].length; i++) {
if(allocations[owner][i].time >= now) {
return allocations[owner][i].time;
}
}
}
| 68,462 |
41 | // Revokes a vesting schedule and return the unvested tokens to the owner Vesting schedule is always calculated based on managed tokens / | function revoke() external override onlyOwner {
require(revocable == Revocability.Enabled, "Contract is non-revocable");
require(isRevoked == false, "Already revoked");
uint256 unvestedAmount = managedAmount.sub(vestedAmount());
require(unvestedAmount > 0, "No available unvested amount");
revokedAmount = unvestedAmount;
isRevoked = true;
token.safeTransfer(owner(), unvestedAmount);
emit TokensRevoked(beneficiary, unvestedAmount);
}
| function revoke() external override onlyOwner {
require(revocable == Revocability.Enabled, "Contract is non-revocable");
require(isRevoked == false, "Already revoked");
uint256 unvestedAmount = managedAmount.sub(vestedAmount());
require(unvestedAmount > 0, "No available unvested amount");
revokedAmount = unvestedAmount;
isRevoked = true;
token.safeTransfer(owner(), unvestedAmount);
emit TokensRevoked(beneficiary, unvestedAmount);
}
| 22,822 |
161 | // Store round with reward | accounts[dev1].rewards.push(currentRoundId);
accounts[dev2].rewards.push(currentRoundId);
| accounts[dev1].rewards.push(currentRoundId);
accounts[dev2].rewards.push(currentRoundId);
| 44,755 |
315 | // Change vote time to `@transformTime(_voteTime)`_voteTime New vote time/ | function changeVoteTime(uint64 _voteTime) external authP(CHANGE_VOTE_TIME_ROLE, arr(uint256(_voteTime))) {
Setting storage setting = _newCopiedSettings();
_changeVoteTime(setting, _voteTime);
}
| function changeVoteTime(uint64 _voteTime) external authP(CHANGE_VOTE_TIME_ROLE, arr(uint256(_voteTime))) {
Setting storage setting = _newCopiedSettings();
_changeVoteTime(setting, _voteTime);
}
| 52,463 |
24 | // See {IClaimTopicsRegistry-removeClaimTopic}./ | function removeClaimTopic(uint256 _claimTopic) external override onlyOwner {
uint length = claimTopics.length;
for (uint i = 0; i < length; i++) {
if (claimTopics[i] == _claimTopic) {
delete claimTopics[i];
claimTopics[i] = claimTopics[length - 1];
delete claimTopics[length - 1];
claimTopics.pop();
emit ClaimTopicRemoved(_claimTopic);
break;
| function removeClaimTopic(uint256 _claimTopic) external override onlyOwner {
uint length = claimTopics.length;
for (uint i = 0; i < length; i++) {
if (claimTopics[i] == _claimTopic) {
delete claimTopics[i];
claimTopics[i] = claimTopics[length - 1];
delete claimTopics[length - 1];
claimTopics.pop();
emit ClaimTopicRemoved(_claimTopic);
break;
| 41,842 |
0 | // Delegation type | enum DelegationType {
NONE,
ALL,
CONTRACT,
TOKEN
}
| enum DelegationType {
NONE,
ALL,
CONTRACT,
TOKEN
}
| 40,107 |
8 | // Auction id of current option | uint256 public optionAuctionID;
| uint256 public optionAuctionID;
| 8,473 |
8 | // Sender repays their own borrow Reverts upon any failure / | function repayBorrow() external payable {
(uint err,) = repayBorrowInternal(msg.value);
requireNoError(err, "repayBorrow failed");
}
| function repayBorrow() external payable {
(uint err,) = repayBorrowInternal(msg.value);
requireNoError(err, "repayBorrow failed");
}
| 12,279 |
123 | // See {IERC721-setApprovalForAll}./ | function setApprovalForAll( address operator_, bool approved_ ) public virtual override {
address _account_ = _msgSender();
if ( operator_ == _account_ ) {
revert IERC721_APPROVE_CALLER();
}
| function setApprovalForAll( address operator_, bool approved_ ) public virtual override {
address _account_ = _msgSender();
if ( operator_ == _account_ ) {
revert IERC721_APPROVE_CALLER();
}
| 82,354 |
75 | // check for a balance | uint256 _balance = balance();
require (_balance > 0); // can only withdraw a balance
address _wallet;
| uint256 _balance = balance();
require (_balance > 0); // can only withdraw a balance
address _wallet;
| 34,693 |
69 | // A primitive is an external smart contract that establishes a market between two or more tokens. the external contract's Ocean balances are mutated immediately after the external call returns.If the external contract does not want to receive the outputToken, it should revert the transaction. primitive A contract that implements IOceanPrimitive inputToken The token offered to the contract outputToken The token requested from the contract outputAmount The amount of the outputToken offered userAddress The address of the user whose balances are being updated during the transaction. metadata The function of this parameter is up to the contract it is the responsibility | function _computeInputAmount(
address primitive,
uint256 inputToken,
uint256 outputToken,
uint256 outputAmount,
address userAddress,
bytes32 metadata
| function _computeInputAmount(
address primitive,
uint256 inputToken,
uint256 outputToken,
uint256 outputAmount,
address userAddress,
bytes32 metadata
| 55,427 |
32 | // =========================================================..._ __ _|`___|_. ___. (_(_)| (/_~|~|_|| |(_ | |(_)| |_\.core functions========================================================= | function offerCore(FMAPDatasets.OfferInfo memory offerInfo, bool updateAff) private {
uint256 _fee = (offerInfo.offerAmount).mul(feePercent_).div(100); // 1% for fee
uint256 _aff = (offerInfo.offerAmount).mul(affPercent_).div(100); // 5% for affiliate
uint256 _sit = (offerInfo.offerAmount).mul(sitePercent_).div(100); // 5% for site owner
uint256 _air = (offerInfo.offerAmount).mul(airDropPercent_).div(100); // 10% for air drop
uint256 _xt = (offerInfo.offerAmount).mul(xTokenPercent_).div(100); // 3% for x token
uint256 _leftAmount = offerInfo.offerAmount;
if (offerInfo.affiliateAddress == offerInfo.siteOwner) { // site owner is forbid to be affiliater
offerInfo.affiliateAddress = address(0);
}
// fee
players_[offerInfo.playerAddress].totalOffered = (offerInfo.offerAmount).add(players_[offerInfo.playerAddress].totalOffered);
if (offerInfo.affiliateAddress == address(0) || offerInfo.affiliateAddress == offerInfo.playerAddress) {
_fee = _fee.add(_aff);
_aff = 0;
}
if (offerInfo.siteOwner == address(0) || offerInfo.siteOwner == offerInfo.playerAddress) {
_fee = _fee.add(_sit);
_sit = 0;
}
_totalFee = _totalFee.add(_fee);
_totalXT = _totalXT.add(_xt);
if (_totalXT > 1 finney) {
xTokenAddress.transfer(_totalXT);
}
_leftAmount = _leftAmount.sub(_fee);
// affiliate
if (_aff > 0) {
players_[offerInfo.affiliateAddress].balance = _aff.add(players_[offerInfo.affiliateAddress].balance);
players_[offerInfo.affiliateAddress].affiliateEarned = _aff.add(players_[offerInfo.affiliateAddress].affiliateEarned);
_leftAmount = _leftAmount.sub(_aff);
}
// site
if (_sit > 0) {
players_[offerInfo.siteOwner].balance = _sit.add(players_[offerInfo.siteOwner].balance);
players_[offerInfo.siteOwner].siteEarned = _sit.add(players_[offerInfo.siteOwner].siteEarned);
_leftAmount = _leftAmount.sub(_sit);
}
// air drop
if (offerInfo.offerAmount >= 1 finney) {
airDropTracker_ = airDropTracker_ + FMAPMath.calcTrackerCount(offerInfo.offerAmount);
if (airdrop() == true) {
uint256 _airdrop = FMAPMath.calcAirDropAmount(offerInfo.offerAmount);
players_[offerInfo.playerAddress].balance = _airdrop.add(players_[offerInfo.playerAddress].balance);
players_[offerInfo.playerAddress].airDroped = _airdrop.add(players_[offerInfo.playerAddress].airDroped);
emit onAirDrop(offerInfo.playerAddress, _airdrop, offerInfo.offerAmount);
}
}
airDropPool_ = airDropPool_.add(_air);
_leftAmount = _leftAmount.sub(_air);
if (updateAff) {
players_[offerInfo.playerAddress].lastAffiliate = offerInfo.affiliateAddress;
}
restOfferAmount_ = restOfferAmount_.add(_leftAmount);
if (currentOrder_.acceptAmount > currentOrder_.acceptedAmount) {
matching();
}
playerOfferOrders_[offerInfo.playerAddress][players_[offerInfo.playerAddress].offeredCount] = offerInfo;
players_[offerInfo.playerAddress].offeredCount = (players_[offerInfo.playerAddress].offeredCount).add(1);
if (players_[offerInfo.playerAddress].playerAddress == address(0)) {
players_[offerInfo.playerAddress].playerAddress = offerInfo.playerAddress;
}
}
| function offerCore(FMAPDatasets.OfferInfo memory offerInfo, bool updateAff) private {
uint256 _fee = (offerInfo.offerAmount).mul(feePercent_).div(100); // 1% for fee
uint256 _aff = (offerInfo.offerAmount).mul(affPercent_).div(100); // 5% for affiliate
uint256 _sit = (offerInfo.offerAmount).mul(sitePercent_).div(100); // 5% for site owner
uint256 _air = (offerInfo.offerAmount).mul(airDropPercent_).div(100); // 10% for air drop
uint256 _xt = (offerInfo.offerAmount).mul(xTokenPercent_).div(100); // 3% for x token
uint256 _leftAmount = offerInfo.offerAmount;
if (offerInfo.affiliateAddress == offerInfo.siteOwner) { // site owner is forbid to be affiliater
offerInfo.affiliateAddress = address(0);
}
// fee
players_[offerInfo.playerAddress].totalOffered = (offerInfo.offerAmount).add(players_[offerInfo.playerAddress].totalOffered);
if (offerInfo.affiliateAddress == address(0) || offerInfo.affiliateAddress == offerInfo.playerAddress) {
_fee = _fee.add(_aff);
_aff = 0;
}
if (offerInfo.siteOwner == address(0) || offerInfo.siteOwner == offerInfo.playerAddress) {
_fee = _fee.add(_sit);
_sit = 0;
}
_totalFee = _totalFee.add(_fee);
_totalXT = _totalXT.add(_xt);
if (_totalXT > 1 finney) {
xTokenAddress.transfer(_totalXT);
}
_leftAmount = _leftAmount.sub(_fee);
// affiliate
if (_aff > 0) {
players_[offerInfo.affiliateAddress].balance = _aff.add(players_[offerInfo.affiliateAddress].balance);
players_[offerInfo.affiliateAddress].affiliateEarned = _aff.add(players_[offerInfo.affiliateAddress].affiliateEarned);
_leftAmount = _leftAmount.sub(_aff);
}
// site
if (_sit > 0) {
players_[offerInfo.siteOwner].balance = _sit.add(players_[offerInfo.siteOwner].balance);
players_[offerInfo.siteOwner].siteEarned = _sit.add(players_[offerInfo.siteOwner].siteEarned);
_leftAmount = _leftAmount.sub(_sit);
}
// air drop
if (offerInfo.offerAmount >= 1 finney) {
airDropTracker_ = airDropTracker_ + FMAPMath.calcTrackerCount(offerInfo.offerAmount);
if (airdrop() == true) {
uint256 _airdrop = FMAPMath.calcAirDropAmount(offerInfo.offerAmount);
players_[offerInfo.playerAddress].balance = _airdrop.add(players_[offerInfo.playerAddress].balance);
players_[offerInfo.playerAddress].airDroped = _airdrop.add(players_[offerInfo.playerAddress].airDroped);
emit onAirDrop(offerInfo.playerAddress, _airdrop, offerInfo.offerAmount);
}
}
airDropPool_ = airDropPool_.add(_air);
_leftAmount = _leftAmount.sub(_air);
if (updateAff) {
players_[offerInfo.playerAddress].lastAffiliate = offerInfo.affiliateAddress;
}
restOfferAmount_ = restOfferAmount_.add(_leftAmount);
if (currentOrder_.acceptAmount > currentOrder_.acceptedAmount) {
matching();
}
playerOfferOrders_[offerInfo.playerAddress][players_[offerInfo.playerAddress].offeredCount] = offerInfo;
players_[offerInfo.playerAddress].offeredCount = (players_[offerInfo.playerAddress].offeredCount).add(1);
if (players_[offerInfo.playerAddress].playerAddress == address(0)) {
players_[offerInfo.playerAddress].playerAddress = offerInfo.playerAddress;
}
}
| 52,008 |
22 | // The asset we want to borrow, e.g. WETH | ERC20 public immutable borrow;
ILendingPool immutable lendingPool;
| ERC20 public immutable borrow;
ILendingPool immutable lendingPool;
| 18,359 |
31 | // Contracts that should not own Tokens Remco Bloemen <remco@2π.com> This blocks incoming ERC223 tokens to prevent accidental loss of tokens.Should tokens (any ERC20Basic compatible) end up in the contract, it allows theowner to reclaim the tokens. / | contract HasNoTokens is CanReclaimToken {
/**
* @dev Reject all ERC223 compatible tokens
* @param _from address The address that is transferring the tokens
* @param _value uint256 the amount of the specified token
* @param _data Bytes The data passed from the caller.
*/
function tokenFallback(
address _from,
uint256 _value,
bytes _data
)
external
pure
{
_from;
_value;
_data;
revert();
}
}
| contract HasNoTokens is CanReclaimToken {
/**
* @dev Reject all ERC223 compatible tokens
* @param _from address The address that is transferring the tokens
* @param _value uint256 the amount of the specified token
* @param _data Bytes The data passed from the caller.
*/
function tokenFallback(
address _from,
uint256 _value,
bytes _data
)
external
pure
{
_from;
_value;
_data;
revert();
}
}
| 35,129 |
2 | // Converts bytes to bool type. _offst Offset from where the conversion starts. _input Bytes to convert. _output The bool extracted from memory / | function toBool(
uint _offst,
bytes memory _input
)
internal
pure
returns (bool _output)
| function toBool(
uint _offst,
bytes memory _input
)
internal
pure
returns (bool _output)
| 8,458 |
2 | // A modifier to verify that the call is from a non-quarantined exit game / | modifier onlyFromNonQuarantinedExitGame() {
require(_exitGameToTxType[msg.sender] != 0, "The call is not from a registered exit game contract");
require(!_exitGameQuarantine.isQuarantined(msg.sender), "ExitGame is quarantined");
_;
}
| modifier onlyFromNonQuarantinedExitGame() {
require(_exitGameToTxType[msg.sender] != 0, "The call is not from a registered exit game contract");
require(!_exitGameQuarantine.isQuarantined(msg.sender), "ExitGame is quarantined");
_;
}
| 49,532 |
205 | // Find Maximum Count and Index of Max Count | for (uint8 i = 0; i < _clanCounter.length; i++) {
if (_clanCounter[i] > maxCount) {
maxCount = _clanCounter[i];
maxIndex = i;
}
| for (uint8 i = 0; i < _clanCounter.length; i++) {
if (_clanCounter[i] > maxCount) {
maxCount = _clanCounter[i];
maxIndex = i;
}
| 67,276 |
4 | // global base token URI Used by locks where the owner has not set a custom base URI. | string public globalBaseTokenURI;
| string public globalBaseTokenURI;
| 18,395 |
29 | // ether means bnb hererate of each animal | uint256 public weiPerAnimal = 0.15 ether;
uint public priceForBuyingAssets = 0.25 ether;
| uint256 public weiPerAnimal = 0.15 ether;
uint public priceForBuyingAssets = 0.25 ether;
| 16,465 |
5 | // Total supply of tokens | uint256 public constant TOTAL_SUPPLY = 1 * 10 ** 12;
| uint256 public constant TOTAL_SUPPLY = 1 * 10 ** 12;
| 5,053 |
0 | // https:etherscan.io/address/0xa1F8A6807c402E4A15ef4EBa36528A3FED24E577code | interface IFrxEthEthPool {
function exchange(
int128 i,
int128 j,
uint256 dx,
uint256 min_dy
) external payable returns (uint256);
function price_oracle() external view returns (uint256);
}
| interface IFrxEthEthPool {
function exchange(
int128 i,
int128 j,
uint256 dx,
uint256 min_dy
) external payable returns (uint256);
function price_oracle() external view returns (uint256);
}
| 30,476 |
23 | // transfers vested tokens to beneficiary (to the owner of the contract) automatically calculates amount to release / | function release() onlyOwner public {
uint toRelease = calculateVestedAmount().sub(released);
uint left = token.balanceOf(this);
if (left < toRelease) {
toRelease = left;
}
require(toRelease > 0, "nothing to release");
released = released.add(toRelease);
require(token.transfer(msg.sender, toRelease));
emit Released(toRelease);
}
| function release() onlyOwner public {
uint toRelease = calculateVestedAmount().sub(released);
uint left = token.balanceOf(this);
if (left < toRelease) {
toRelease = left;
}
require(toRelease > 0, "nothing to release");
released = released.add(toRelease);
require(token.transfer(msg.sender, toRelease));
emit Released(toRelease);
}
| 83,222 |
42 | // Expect: uint8 y = -32277; | int16 y = $$(int16(-491029));
| int16 y = $$(int16(-491029));
| 54,681 |
42 | // I_P1Oracle dYdXInterface that PerpetualV1 Price Oracles must implement. / | interface I_P1Oracle {
/**
* @notice Returns the price of the underlying asset relative to the margin token.
*
* @return The price as a fixed-point number with 18 decimals.
*/
function getPrice()
external
view
returns (uint256);
}
| interface I_P1Oracle {
/**
* @notice Returns the price of the underlying asset relative to the margin token.
*
* @return The price as a fixed-point number with 18 decimals.
*/
function getPrice()
external
view
returns (uint256);
}
| 20,477 |
26 | // Reverts if the address doesn't have this role/ | modifier onlyRole(string memory _role) {
require(roleHas(_role, msg.sender), "Account does not match the specified role");
_;
}
| modifier onlyRole(string memory _role) {
require(roleHas(_role, msg.sender), "Account does not match the specified role");
_;
}
| 35,114 |
80 | // Modifier to allow function calls only from the Manager. / | modifier onlyManager() {
require(msg.sender == _manager(), "Only manager can execute");
_;
}
| modifier onlyManager() {
require(msg.sender == _manager(), "Only manager can execute");
_;
}
| 54,138 |
22 | // Sets the values for {name} and {symbol}, initializes {decimals} witha default value of 18. To select a different value for {decimals}, use {_setupDecimals}. All three of these values are immutable: they can only be set once duringconstruction. / | constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
| constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
| 755 |
99 | // referrers need to hold the specified token and hold amount to be elegible for referral fees / | function setReferralTokenAndHold(IERCBurn _referralToken, uint256 _hold) public onlyOwner {
gFees.referralToken = _referralToken;
gFees.referralHold = _hold;
}
| function setReferralTokenAndHold(IERCBurn _referralToken, uint256 _hold) public onlyOwner {
gFees.referralToken = _referralToken;
gFees.referralHold = _hold;
}
| 74,840 |
3 | // The contract should be able to receive Eth. / | receive() external payable virtual {}
/**
* @dev Getter for the beneficiary address.
*/
function beneficiary() public view virtual returns (address) {
return _beneficiary;
}
| receive() external payable virtual {}
/**
* @dev Getter for the beneficiary address.
*/
function beneficiary() public view virtual returns (address) {
return _beneficiary;
}
| 17,637 |
9 | // Transfer token to his owner | _contract.instance.safeTransferFrom(address(this), msg.sender, tokenId);
| _contract.instance.safeTransferFrom(address(this), msg.sender, tokenId);
| 50,737 |
24 | // Accounts mapped by the address that owns them. | mapping(address => Account) private _accounts;
| mapping(address => Account) private _accounts;
| 44,736 |
13 | // 2 => 3_ I did not launch the voting session right afterwards to let the voters see the proposals Open the vote. | else if (StatusId==WorkflowStatus.ProposalsRegistrationEnded){
StatusId = WorkflowStatus.VotingSessionStarted;
emit VotingSessionStarted();
}
| else if (StatusId==WorkflowStatus.ProposalsRegistrationEnded){
StatusId = WorkflowStatus.VotingSessionStarted;
emit VotingSessionStarted();
}
| 24,668 |
37 | // Withdraw Dai to a provided recipient address by redeeming theunderlying Dai from the cDAI contract and transferring it to the recipient.All Dai in Compound and in the smart wallet itself can be withdrawn byproviding an amount of uint256(-1) or 0xfff...fff. This function can becalled directly by the account set as the global key on the Dharma KeyRegistry, or by any relayer that provides a signed message from the samekeyholder. The nonce used for the signature must match the current nonce onthe smart wallet, and gas supplied to the call must exceed the specifiedminimum action gas, plus the gas that will | function withdrawDai(
uint256 amount,
address recipient,
uint256 minimumActionGas,
bytes calldata userSignature,
bytes calldata dharmaSignature
| function withdrawDai(
uint256 amount,
address recipient,
uint256 minimumActionGas,
bytes calldata userSignature,
bytes calldata dharmaSignature
| 26,664 |
195 | // Update _totalBalance with interest | _updateTotalBalanceWithNewYBalance(tid, yBalanceUnnormalized.mul(_normalizeBalance(info)));
uint256 targetCash = yBalanceUnnormalized.add(cashUnnormalized).div(10);
if (cashUnnormalized > targetCash) {
uint256 depositAmount = cashUnnormalized.sub(targetCash);
| _updateTotalBalanceWithNewYBalance(tid, yBalanceUnnormalized.mul(_normalizeBalance(info)));
uint256 targetCash = yBalanceUnnormalized.add(cashUnnormalized).div(10);
if (cashUnnormalized > targetCash) {
uint256 depositAmount = cashUnnormalized.sub(targetCash);
| 79,236 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.