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 |
|---|---|---|---|---|
71 | // Pays the given amount of given tokens to the specified address./Transfers tokens to the given address decreasing balance of the user which is paying. Requires that the paying user has account for thegiven token and enough tokens stored there. At the end, it emits Payment event/token Address of the token to be paid w... | function pay(ERC20 token, uint256 amount, address to, string memory note)
external;
| function pay(ERC20 token, uint256 amount, address to, string memory note)
external;
| 23,517 |
110 | // The implementation address of this contract./This has to be immutable to persist across delegatecalls. | address immutable private _implementation;
| address immutable private _implementation;
| 14,913 |
146 | // Extend parent behavior erc20Token ERC20 Token _value Amount contributed / | function _forwardFundsToken(IERC20 erc20Token, uint256 _value) internal {
erc20Token.transferFrom(_msgSender(), address(_vault), _value);
}
| function _forwardFundsToken(IERC20 erc20Token, uint256 _value) internal {
erc20Token.transferFrom(_msgSender(), address(_vault), _value);
}
| 65,053 |
118 | // Bitmask for `blockNumber` | uint256 constant _BITMASK_BLOCK_NUM = (1 << _BITWIDTH_BLOCK_NUM) -1;
| uint256 constant _BITMASK_BLOCK_NUM = (1 << _BITWIDTH_BLOCK_NUM) -1;
| 13,260 |
14 | // if every thing is good add him to the request approversand increase the approvalCount by one. | request.approvals[msg.sender] = true;
request.approvalCount++;
| request.approvals[msg.sender] = true;
request.approvalCount++;
| 36,171 |
128 | // Allows owner of the contract to transfer tokens on behalf of user. User will need to approve this contract to spend tokens on his/her behalf on Paraswap platform/ | contract TokenTransferProxy is Ownable {
using SafeERC20 for IERC20;
IGST2 private _gst2;
address private _gstHolder;
constructor(address gst2, address gstHolder) public {
_gst2 = IGST2(gst2);
_gstHolder = gstHolder;
}
function getGSTHolder() external view returns(address) {
... | contract TokenTransferProxy is Ownable {
using SafeERC20 for IERC20;
IGST2 private _gst2;
address private _gstHolder;
constructor(address gst2, address gstHolder) public {
_gst2 = IGST2(gst2);
_gstHolder = gstHolder;
}
function getGSTHolder() external view returns(address) {
... | 8,425 |
102 | // This will assign ownership, and also emit the Transfer event as per ERC721 draft | _transferToken(address(0), collectibleOwner, tokenId);
| _transferToken(address(0), collectibleOwner, tokenId);
| 54,590 |
24 | // Allows owner to withdraw funds generated from sale. / | function withdrawAll() external onlyOwner {
address _to = msg.sender;
uint256 contractBalance = address(this).balance;
require(contractBalance > 0, "NO ETHER TO WITHDRAW");
payable(_to).transfer(contractBalance);
emit WithdrawAllEvent(_to, contractBalance);
}
| function withdrawAll() external onlyOwner {
address _to = msg.sender;
uint256 contractBalance = address(this).balance;
require(contractBalance > 0, "NO ETHER TO WITHDRAW");
payable(_to).transfer(contractBalance);
emit WithdrawAllEvent(_to, contractBalance);
}
| 23,975 |
19 | // approves `approvingContract` to spend the ERC20 balance this approves to max uint256 value, make sure the `approvingContract` is safe called only by owner of this mediator tokenAddress the address of the ERC20 token to approve approvingContract the address of the account to approve for spending / | function approveErc20(address tokenAddress, address approvingContract) external;
| function approveErc20(address tokenAddress, address approvingContract) external;
| 6,652 |
194 | // Fail gracefully if protocol has insufficient cash If protocol has insufficient cash, the sub operation will underflow. | localResults.currentCash = getCash(asset);
(err, localResults.updatedCash) = sub(localResults.currentCash, localResults.withdrawAmount);
if (err != Error.NO_ERROR) {
return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.WITHDRAW_TRANSFER_OUT_NOT_POSSIBLE);
}
| localResults.currentCash = getCash(asset);
(err, localResults.updatedCash) = sub(localResults.currentCash, localResults.withdrawAmount);
if (err != Error.NO_ERROR) {
return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.WITHDRAW_TRANSFER_OUT_NOT_POSSIBLE);
}
| 3,635 |
15 | // Unshare a previously shared file with a specific user/Removes the file's address from sharedFiles and recipientFiles/_indexOwner The index of file in sharedFiles/_indexRecipient The index of file in recipientFiles/_recipient The address of recipient/_from the Address of uploader | function stopSharing(uint _indexOwner, uint _indexRecipient, address _recipient, address _from) public isUploader(_from) {
removeByIndex(_indexOwner, sharedFiles[_from]);
removeByIndex(_indexRecipient, recipientFiles[_recipient]);
}
| function stopSharing(uint _indexOwner, uint _indexRecipient, address _recipient, address _from) public isUploader(_from) {
removeByIndex(_indexOwner, sharedFiles[_from]);
removeByIndex(_indexRecipient, recipientFiles[_recipient]);
}
| 29,672 |
104 | // Burn Wallet | _transf(address(this), _burnWalet, _burnAmount);
emit RewardsDistributed(taxFee);
| _transf(address(this), _burnWalet, _burnAmount);
emit RewardsDistributed(taxFee);
| 15,403 |
62 | // still has some tokens need to be released in future | owned.freezeAccount(frozenAddr, true);
| owned.freezeAccount(frozenAddr, true);
| 24,245 |
22 | // 将最后一个点的右儿子变为0,即变为虚边 | uint32 son = 0;
while(x>0){
| uint32 son = 0;
while(x>0){
| 23,882 |
221 | // PIX token, including:- ability for holders to burn (destroy) their tokens - ability admin to take snapshot at any moment - a minter role that allows for token minting (creation) - a pauser role that allows to stop all token transfers - a freezer role that allows to freeze all token of an address to be transfered | * This contract uses {AccessControl} to lock permissioned functions using the
* different roles - head to its documentation for details.
*
* The account that deploys the contract will be granted the minter, pauser and freezer
* roles, as well as the default admin role, which will let it grant both minter, pauser
... | * This contract uses {AccessControl} to lock permissioned functions using the
* different roles - head to its documentation for details.
*
* The account that deploys the contract will be granted the minter, pauser and freezer
* roles, as well as the default admin role, which will let it grant both minter, pauser
... | 4,113 |
199 | // Get ether price based on current token supply | function getCurrentPrice() public pure returns (uint64) {
return 42_000_000_000_000_000;
}
| function getCurrentPrice() public pure returns (uint64) {
return 42_000_000_000_000_000;
}
| 18,595 |
12 | // isTransferAllowed checks if SOULBOUND setting is enable, if yes, diable all transferability of tokens. / | modifier isTransferAllowed() {
if (_SOULBOUND) revert CommonError.TransferNotAllowed();
_;
}
| modifier isTransferAllowed() {
if (_SOULBOUND) revert CommonError.TransferNotAllowed();
_;
}
| 7,930 |
18 | // plus function for ERC20 of OpenZeppelin | function permit(address owner_, address spender_, uint amount_, uint deadline_, uint8 v_, bytes32 r_, bytes32 s_) external {
require(deadline_ >= block.timestamp, 'SPTERC20: permit expired!');
bytes32 digest = keccak256(
abi.encodePacked(
'\x19\x01',
DOMAI... | function permit(address owner_, address spender_, uint amount_, uint deadline_, uint8 v_, bytes32 r_, bytes32 s_) external {
require(deadline_ >= block.timestamp, 'SPTERC20: permit expired!');
bytes32 digest = keccak256(
abi.encodePacked(
'\x19\x01',
DOMAI... | 2,848 |
112 | // event for claimed ether loggingaccount user claiming the etheramount ether claimed/ | event Claimed(address indexed account, uint256 amount);
| event Claimed(address indexed account, uint256 amount);
| 39,699 |
32 | // See {ERC721-_beforeTokenTransfer}. | function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId_,
uint256 quantity
) internal virtual override {
super._beforeTokenTransfers(from, to, startTokenId_, quantity);
| function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId_,
uint256 quantity
) internal virtual override {
super._beforeTokenTransfers(from, to, startTokenId_, quantity);
| 6,946 |
24 | // Compound's repay ETH function signature is: repayBorrow(). No return, revert on fail | bytes memory callData = abi.encodeWithSignature("repayBorrow()");
return (address(_cToken), _repayNotional, callData);
| bytes memory callData = abi.encodeWithSignature("repayBorrow()");
return (address(_cToken), _repayNotional, callData);
| 8,116 |
24 | // Set account that can mint new tokens | function setMinter(address _newMinter)
public
onlyOwner
returns (bool success)
| function setMinter(address _newMinter)
public
onlyOwner
returns (bool success)
| 36,801 |
36 | // ------------------------- PRIVATE FUNCTIONS ------------------------- //Internal logic extraction of processInputOrders()/_nftId The id of the NFT to update/_batchedOrders The order to execute | function _processInputOrders(uint256 _nftId, BatchedInputOrders[] calldata _batchedOrders) private {
uint256 batchedOrdersLength = _batchedOrders.length;
require(batchedOrdersLength != 0, "NF: INVALID_MULTI_ORDERS");
require(nestedRecords.getAssetReserve(_nftId) == address(reserve), "NF: RES... | function _processInputOrders(uint256 _nftId, BatchedInputOrders[] calldata _batchedOrders) private {
uint256 batchedOrdersLength = _batchedOrders.length;
require(batchedOrdersLength != 0, "NF: INVALID_MULTI_ORDERS");
require(nestedRecords.getAssetReserve(_nftId) == address(reserve), "NF: RES... | 60,192 |
9 | // Calculate fee share | uint256 feeShare = getUserConfirmedRewards(_tokenTicker, _account, _index);
if(feeShare == 0)
return;
require(totalFees[_tokenTicker] >= feeShare, "INSUFFICIENT_FEES");
| uint256 feeShare = getUserConfirmedRewards(_tokenTicker, _account, _index);
if(feeShare == 0)
return;
require(totalFees[_tokenTicker] >= feeShare, "INSUFFICIENT_FEES");
| 10,314 |
87 | // Emitted when a loan is initially created / | event LoanCreated(LoanLibrary.LoanTerms terms, uint256 loanId);
| event LoanCreated(LoanLibrary.LoanTerms terms, uint256 loanId);
| 24,418 |
76 | // Checks for token ownership. | function _owns(address claimant, uint256 _tokenId)
private
view
| function _owns(address claimant, uint256 _tokenId)
private
view
| 40,305 |
146 | // Initialize the first epoch pointing to the first controller | controllers.push(ControllerInfo({controllerAddress: _witnetRequestBoardAddress, lastId: 0}));
| controllers.push(ControllerInfo({controllerAddress: _witnetRequestBoardAddress, lastId: 0}));
| 47,586 |
164 | // update rewardCycleBlock | nextAvailableClaimDate[msg.sender] = block.timestamp + getRewardCycleBlock();
emit ClaimBNBSuccessfully(msg.sender, reward, nextAvailableClaimDate[msg.sender]);
| nextAvailableClaimDate[msg.sender] = block.timestamp + getRewardCycleBlock();
emit ClaimBNBSuccessfully(msg.sender, reward, nextAvailableClaimDate[msg.sender]);
| 42,961 |
2 | // Staked NFT Total ValueLP token total supply | uint256 private _totalValue = 0;
uint256 public constant ROUND_DURATION = 365 days;
uint256 public rewardAllocation = 9998 * 1e18;
uint256 public resetTimestamp = 0;
uint256 public lastUpdateTimestamp = 0;
uint256 public rewardRate = 0;
uint256 public rewardPerTokenStored = 0;
| uint256 private _totalValue = 0;
uint256 public constant ROUND_DURATION = 365 days;
uint256 public rewardAllocation = 9998 * 1e18;
uint256 public resetTimestamp = 0;
uint256 public lastUpdateTimestamp = 0;
uint256 public rewardRate = 0;
uint256 public rewardPerTokenStored = 0;
| 22,683 |
42 | // A mapping from hero ID to the refunded fee. | mapping(uint => uint) public heroIdToRefundedFee;
| mapping(uint => uint) public heroIdToRefundedFee;
| 26,458 |
136 | // This will suffice for checking _exists(nextTokenId), as a burned slot cannot contain the zero address. | if (nextTokenId != _currentIndex) {
nextSlot.addr = from;
nextSlot.startTimestamp = prevOwnership.startTimestamp;
}
| if (nextTokenId != _currentIndex) {
nextSlot.addr = from;
nextSlot.startTimestamp = prevOwnership.startTimestamp;
}
| 3,728 |
44 | // Checks if the account should be allowed to redeem tokens in the given market jToken The market to verify the redeem against redeemer The account which would redeem the tokens redeemTokens The number of jTokens to exchange for the underlying asset in the marketreturn 0 if the redeem is allowed, otherwise a semi-opaqu... | function redeemAllowed(
address jToken,
address redeemer,
uint256 redeemTokens
| function redeemAllowed(
address jToken,
address redeemer,
uint256 redeemTokens
| 8,575 |
69 | // spin ! | else
{
uint8 wheelResult;
| else
{
uint8 wheelResult;
| 50,247 |
5 | // add the stake to the option | prediction[msg.sender] = _prediction;
amountStaked[msg.sender] = _stakeAmount;
uniquePredictionValue[_prediction] += _stakeAmount;
totalAmountStaked += _stakeAmount;
| prediction[msg.sender] = _prediction;
amountStaked[msg.sender] = _stakeAmount;
uniquePredictionValue[_prediction] += _stakeAmount;
totalAmountStaked += _stakeAmount;
| 15,081 |
3 | // Variables enteras con signo | int mi_primer_entero_con_signo;
int mi_numero = -32;
int mi_numero_2 = 65;
| int mi_primer_entero_con_signo;
int mi_numero = -32;
int mi_numero_2 = 65;
| 36,041 |
25 | // Allows the owner to revoke the vesting. Tokens already vestedremain in the contract, the rest are returned to the owner. token ERC20 token which is being vested / | function revoke(ERC20Basic token) public onlyOwner {
require(revocable);
require(!revoked[token]);
uint256 balance = token.balanceOf(this);
uint256 unreleased = releasableAmount(token);
uint256 refund = balance.sub(unreleased);
revoked[token] = true;
token.safeTransfer(owner, refund);
... | function revoke(ERC20Basic token) public onlyOwner {
require(revocable);
require(!revoked[token]);
uint256 balance = token.balanceOf(this);
uint256 unreleased = releasableAmount(token);
uint256 refund = balance.sub(unreleased);
revoked[token] = true;
token.safeTransfer(owner, refund);
... | 7,049 |
6 | // Modifiers | modifier onlyAdmin {
require(msg.sender == admin); // Check: "Only the admin can call this function"
_;
}
| modifier onlyAdmin {
require(msg.sender == admin); // Check: "Only the admin can call this function"
_;
}
| 26,630 |
70 | // Mapping from token ID to account balances | mapping (uint256 => mapping(address => uint256)) private _balances;
| mapping (uint256 => mapping(address => uint256)) private _balances;
| 4,964 |
36 | // add to the output | n = 0;
for (i = 0; i < _agreementClasses.length; ++i) {
if ((bitmap & (1 << i)) > 0) {
agreementClasses[n++] = _agreementClasses[i];
}
| n = 0;
for (i = 0; i < _agreementClasses.length; ++i) {
if ((bitmap & (1 << i)) > 0) {
agreementClasses[n++] = _agreementClasses[i];
}
| 33,740 |
81 | // Transfers tokens held by timelock to beneficiary.only owner can call this method as it will write new TVL metric valueinto the holder contract / | function release(uint256 _newTVL) public onlyOwner {
// solhint-disable-next-line not-rely-on-time
require(block.timestamp >= _firstReleaseTime, "current time before release time");
require(block.timestamp > _lastReleaseTime + RELEASE_INTERVAL, "release interval is not passed");
requ... | function release(uint256 _newTVL) public onlyOwner {
// solhint-disable-next-line not-rely-on-time
require(block.timestamp >= _firstReleaseTime, "current time before release time");
require(block.timestamp > _lastReleaseTime + RELEASE_INTERVAL, "release interval is not passed");
requ... | 12,359 |
491 | // Check onchain authorization | S.requireAuthorizedTx(accountUpdate.owner, auxData.signature, txHash);
| S.requireAuthorizedTx(accountUpdate.owner, auxData.signature, txHash);
| 32,348 |
8 | // 构造函数 | function voteDemo(bytes8[] peposposalName){
// 初始化投票的发起人,就是当前合约的部署者
chairperson = msg.sender;
// 给发起人投票权
voters[chairperson].weight = 1;
// 初始化投票的主题
for(uint i = 0; i < peposposalName.length; i++){
posposals.push(Posposal({name:peposposalName[i],v... | function voteDemo(bytes8[] peposposalName){
// 初始化投票的发起人,就是当前合约的部署者
chairperson = msg.sender;
// 给发起人投票权
voters[chairperson].weight = 1;
// 初始化投票的主题
for(uint i = 0; i < peposposalName.length; i++){
posposals.push(Posposal({name:peposposalName[i],v... | 49,684 |
109 | // IRToken.getSavingAssetBalance implementation | function getSavingAssetBalance() external view
| function getSavingAssetBalance() external view
| 51,391 |
3 | // strike price | uint strikePrice;
| uint strikePrice;
| 15,616 |
85 | // See {IERC721-isApprovedForAll}. / | function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
| function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
| 1,801 |
237 | // Remit the fee in sUSDs | issuer().synths(sUSD).issue(feePool().FEE_ADDRESS(), fee);
| issuer().synths(sUSD).issue(feePool().FEE_ADDRESS(), fee);
| 24,440 |
105 | // @inheritdoc ActionBase | function executeAction(
bytes[] memory _callData,
bytes[] memory _subData,
uint8[] memory _paramMapping,
bytes32[] memory _returnValues
| function executeAction(
bytes[] memory _callData,
bytes[] memory _subData,
uint8[] memory _paramMapping,
bytes32[] memory _returnValues
| 13,939 |
3 | // buyFee, if decimal is not 18, please reset it | uint256 public buyFee = 2857; // 28.57% or 0.2857 Banana
| uint256 public buyFee = 2857; // 28.57% or 0.2857 Banana
| 31,406 |
72 | // register wallets for fee sharing/ | function setFeeSharingValue(uint feeBps) public onlyAdmin {
require(feeBps < 10000);
feeSharingBps = feeBps;
}
| function setFeeSharingValue(uint feeBps) public onlyAdmin {
require(feeBps < 10000);
feeSharingBps = feeBps;
}
| 29,880 |
25 | // Params: address, uint256[] Return: Error (if the sender and the recipient doesn't meet the requirements) or Token Transfer (otherwise) / | function transferTokens(address _to, uint256[] _tokenId) public checkIsIdentity(msg.sender) checkIsIdentity(_to){
require(msg.sender != _to);
require(_tokenId.length != 0);
require(_tokenId.length <= 10);
require(_to != address(0));
for(uint256 i = 0; i < _tokenId.length; i++){
... | function transferTokens(address _to, uint256[] _tokenId) public checkIsIdentity(msg.sender) checkIsIdentity(_to){
require(msg.sender != _to);
require(_tokenId.length != 0);
require(_tokenId.length <= 10);
require(_to != address(0));
for(uint256 i = 0; i < _tokenId.length; i++){
... | 24,589 |
7 | // 授予用户投票权利 | function giveRightToVote(address votor) public returns(bool result){
//只有主席才能授权
require(msg.sender == chairperson);
require(voters[votor].voted == false);
require(voters[votor].weight == 0);
voters[votor].weight = 1;
return true;
}
| function giveRightToVote(address votor) public returns(bool result){
//只有主席才能授权
require(msg.sender == chairperson);
require(voters[votor].voted == false);
require(voters[votor].weight == 0);
voters[votor].weight = 1;
return true;
}
| 12,133 |
100 | // Sets {decimals} to a value other than the default one of 18. WARNING: This function should only be called from the constructor. Mostapplications that interact with token contracts will not expect{decimals} to ever change, and may work incorrectly if it does. / | function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
| function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
| 39,510 |
205 | // Checks if a forced withdrawal is pending for an account balance./ accountID The accountID of the account to check./ token The token address/ return True if a request is pending, false otherwise | function isForcedWithdrawalPending(
uint32 accountID,
address token
)
external
virtual
view
returns (bool);
| function isForcedWithdrawalPending(
uint32 accountID,
address token
)
external
virtual
view
returns (bool);
| 24,017 |
68 | // Only allow one type of operation - buy, or sell, per tx | require(mappedAddresses[from]._lastTxBuy != uint32(block.number), "SSH: SWCH");
mappedAddresses[from]._lastTxSell = uint32(block.number);
| require(mappedAddresses[from]._lastTxBuy != uint32(block.number), "SSH: SWCH");
mappedAddresses[from]._lastTxSell = uint32(block.number);
| 22,965 |
10 | // Borrows tokens on the given position. | function borrow(
address _owner,
uint _pid,
uint _amount
) external;
| function borrow(
address _owner,
uint _pid,
uint _amount
) external;
| 28,665 |
170 | // Get characterSheetType count / | function characterSheetTypeCount() public view returns (uint256) {
return characterSheetTypes.length;
}
| function characterSheetTypeCount() public view returns (uint256) {
return characterSheetTypes.length;
}
| 36,602 |
23 | // Fulfill on-demand price requests | function fulfill(
bytes32 requestId,
uint price
| function fulfill(
bytes32 requestId,
uint price
| 14,347 |
10 | // ============ State Variables ============ / represents total distribution for locked balances | mapping(address => uint256) distribution;
| mapping(address => uint256) distribution;
| 31,870 |
0 | // ERC20Basic/Simpler version of ERC20 interface/ErdemOzgen | contract HelloWorld {
string public greet = "Hello World!";
} | contract HelloWorld {
string public greet = "Hello World!";
} | 21,263 |
2 | // VIEW FUNCTIONS // Return the index of the given token address. Reverts if no matchingtoken is found. tokenAddress address of the tokenreturn the index of the given token address / | function _getTokenIndex(address tokenAddress) internal view returns (uint8) {
uint8 index = tokenIndexes[tokenAddress];
require(address(getToken(index)) == tokenAddress, "Token does not exist");
return index;
}
| function _getTokenIndex(address tokenAddress) internal view returns (uint8) {
uint8 index = tokenIndexes[tokenAddress];
require(address(getToken(index)) == tokenAddress, "Token does not exist");
return index;
}
| 17,165 |
33 | // Creates the request Stores the hash of the params as the on-chain commitment for the request.Emits OracleRequest event for the validator to detect. _sender The sender of the request _payment The amount of payment given (specified in wei) _specId The Job Specification ID _callbackAddress The callback address for the ... | function oracleRequest(
address _sender,
uint256 _payment,
bytes32 _specId,
address _callbackAddress,
bytes4 _callbackFunction,
uint256 _nonce,
bytes calldata data
)
external
| function oracleRequest(
address _sender,
uint256 _payment,
bytes32 _specId,
address _callbackAddress,
bytes4 _callbackFunction,
uint256 _nonce,
bytes calldata data
)
external
| 15,536 |
7 | // 1001.digital/Handle NFT Metadata stored on IPFS | abstract contract WithIPFSMetaData is ERC721 {
using Strings for uint256;
/// @dev Emitted when the content identifyer changes
event MetadataURIChanged(string indexed baseURI);
/// @dev The content identifier of the folder containing all JSON files.
string public cid;
/// Instantiate the cont... | abstract contract WithIPFSMetaData is ERC721 {
using Strings for uint256;
/// @dev Emitted when the content identifyer changes
event MetadataURIChanged(string indexed baseURI);
/// @dev The content identifier of the folder containing all JSON files.
string public cid;
/// Instantiate the cont... | 23,156 |
10 | // If we haven't set the starting index, set the starting index block. | if (startingIndexBlock == 0) {
startingIndexBlock = block.number;
}
| if (startingIndexBlock == 0) {
startingIndexBlock = block.number;
}
| 13,535 |
176 | // TODO: possibly comply with the flash loan standard https:eips.ethereum.org/EIPS/eip-3156 - however, the more I reflect on this, the less keen I am due to gas and simplicityexample: a user must hold 10% of SCX total supply or user must hold an NFTThe initial arbiter will have no constraints.The flashloan system on be... | function grantFlashLoan(uint256 amount, address flashLoanContract)
external
| function grantFlashLoan(uint256 amount, address flashLoanContract)
external
| 24,070 |
57 | // Calculates the amount of token to get based on amount of ETH | function getAmount(uint amount) public view returns (uint) {
return ((amount * terms.ethPrice) / getPrice());
}
| function getAmount(uint amount) public view returns (uint) {
return ((amount * terms.ethPrice) / getPrice());
}
| 13,674 |
145 | // Set if an address is excluded from max transaction | function excludeFromMaxTransaction(
address updAds,
bool isEx
| function excludeFromMaxTransaction(
address updAds,
bool isEx
| 31,664 |
99 | // Optional mapping for token URIs | mapping(uint256 => string) private _tokenURIs;
| mapping(uint256 => string) private _tokenURIs;
| 40,780 |
42 | // Internal function to burn a specific token Reverts if the token does not exist _tokenId uint256 ID of the token being burned by the msg.sender / | function _burn(address _owner, uint256 _tokenId) internal {
clearApproval(_owner, _tokenId);
removeTokenFrom(_owner, _tokenId);
emit Transfer(_owner, address(0), _tokenId);
}
| function _burn(address _owner, uint256 _tokenId) internal {
clearApproval(_owner, _tokenId);
removeTokenFrom(_owner, _tokenId);
emit Transfer(_owner, address(0), _tokenId);
}
| 25,722 |
111 | // PartialCommonOwnership721/Simon de la Rouviere, Will Holley/Extends the ERC721 standard by requiring tax payments from a token's current owner/ using a Harberger Tax model; if payments are not made, the token is repossessed by the contract/ and can be repurchased at any price > 0./This code was originally forked fro... | contract PartialCommonOwnership721 is ERC721 {
//////////////////////////////
/// State
//////////////////////////////
/// @notice Single (for now) beneficiary of tax payments.
address payable public beneficiary;
/// @notice Mapping from token ID to token price in Wei.
mapping(uint256 => uint256) public... | contract PartialCommonOwnership721 is ERC721 {
//////////////////////////////
/// State
//////////////////////////////
/// @notice Single (for now) beneficiary of tax payments.
address payable public beneficiary;
/// @notice Mapping from token ID to token price in Wei.
mapping(uint256 => uint256) public... | 37,515 |
25 | // Cancel a waiting order a user who created the order first with the given order id can only cancel the order orderId order id that has to be cancelled / | function cancelOrder(bytes16 orderId) external {
Order memory order = orderMap[orderId];
if (msg.sender != order.sender)
revert CancelOrderFailure(
CancelOrderFailureReason.ONLY_ORDER_CREATOR_CANCEL
);
if (order.status != OrderStatus.AWAITING_DELIVERY)... | function cancelOrder(bytes16 orderId) external {
Order memory order = orderMap[orderId];
if (msg.sender != order.sender)
revert CancelOrderFailure(
CancelOrderFailureReason.ONLY_ORDER_CREATOR_CANCEL
);
if (order.status != OrderStatus.AWAITING_DELIVERY)... | 29,506 |
5 | // Calculates the Dai savings rate per blockreturn The Dai savings rate per block (as a percentage, and scaled by BASE) / | function dsrPerBlock() public view returns (uint) {
return (pot.dsr() - RAY_BASE) // scaled RAY_BASE aka RAY, and includes an extra "ONE" before subtraction
/ RAY_TO_BASE_SCALE // descale to BASE
* SECONDS_PER_BLOCK; // seconds per block
}
| function dsrPerBlock() public view returns (uint) {
return (pot.dsr() - RAY_BASE) // scaled RAY_BASE aka RAY, and includes an extra "ONE" before subtraction
/ RAY_TO_BASE_SCALE // descale to BASE
* SECONDS_PER_BLOCK; // seconds per block
}
| 20,371 |
166 | // File: contracts/WitnetRequestBoardProxy.sol/ Witnet Request Board Proxy Contract to act as a proxy between the Witnet Bridge Interface and Contracts inheriting UsingWitnet. Witnet Foundation / | contract WitnetRequestBoardProxy {
// Struct if the information of each controller
struct ControllerInfo {
// Address of the Controller
address controllerAddress;
// The lastId of the previous Controller
uint256 lastId;
}
// Witnet Request Board contract that is currently being used
WitnetRe... | contract WitnetRequestBoardProxy {
// Struct if the information of each controller
struct ControllerInfo {
// Address of the Controller
address controllerAddress;
// The lastId of the previous Controller
uint256 lastId;
}
// Witnet Request Board contract that is currently being used
WitnetRe... | 60,424 |
62 | // Performs signature verification. Throws or reverts if unable to verify the record.name The name of the RRSIG record, in DNS label-sequence format. data The original data to verify. proof A DS or DNSKEY record that's already verified by the oracle. / | function verifySignature(bytes memory name, RRUtils.SignedSet memory rrset, RRSetWithSignature memory data, bytes memory proof) internal view {
// o The RRSIG RR's Signer's Name field MUST be the name of the zone
// that contains the RRset.
require(rrset.signerName.length <= name.length)... | function verifySignature(bytes memory name, RRUtils.SignedSet memory rrset, RRSetWithSignature memory data, bytes memory proof) internal view {
// o The RRSIG RR's Signer's Name field MUST be the name of the zone
// that contains the RRset.
require(rrset.signerName.length <= name.length)... | 24,552 |
144 | // Burn a given discreet NFT if it is owned, approved or reclaimable.Tokens become reclaimable after ~4 million blocks without a transfer. / | function burn(uint256 tokenId) external override {
require(
tokenId < 0x510,
"discreet: cannot burn out-of-range token"
);
// Only enforce check if tokenId has not reached reclaimable threshold.
if (!isReclaimable(tokenId)) {
require(
... | function burn(uint256 tokenId) external override {
require(
tokenId < 0x510,
"discreet: cannot burn out-of-range token"
);
// Only enforce check if tokenId has not reached reclaimable threshold.
if (!isReclaimable(tokenId)) {
require(
... | 28,166 |
229 | // Cache the end of the memory to calculate the length later. | let end := str
| let end := str
| 32,903 |
18 | // Update the given pool's ability to withdraw tokens Note contract owner is meant to be a governance contract allowing RENA governance consensus | function setPoolWithdrawable(
uint256 _pid,
bool _withdrawable
| function setPoolWithdrawable(
uint256 _pid,
bool _withdrawable
| 36,501 |
4 | // ============ External Getter Functions ============ //Return calldata for Uniswap V3 SwapRouter _sourceTokenAddress of source token to be sold_destinationToken Address of destination token to buy_destinationAddress Address that assets should be transferred to_sourceQuantity Amount of source token to sell_minDestinat... | function getTradeCalldata(
address _sourceToken,
address _destinationToken,
address _destinationAddress,
uint256 _sourceQuantity,
uint256 _minDestinationQuantity,
bytes calldata _data
)
external
view
| function getTradeCalldata(
address _sourceToken,
address _destinationToken,
address _destinationAddress,
uint256 _sourceQuantity,
uint256 _minDestinationQuantity,
bytes calldata _data
)
external
view
| 47,951 |
30 | // Fired when tokens are transferred from one account to another | event Transfer
(
address indexed from,
address indexed to,
uint256 value
);
| event Transfer
(
address indexed from,
address indexed to,
uint256 value
);
| 1,865 |
26 | // dYdX flash loan contract | interface ISoloMargin {
function operate(Account.Info[] memory accounts, Actions.ActionArgs[] memory actions) external;
}
| interface ISoloMargin {
function operate(Account.Info[] memory accounts, Actions.ActionArgs[] memory actions) external;
}
| 56,358 |
10 | // Assigned name, immutable. | string public name;
string public symbol;
| string public name;
string public symbol;
| 51,775 |
60 | // 41% | uint256 public constant publicSupply = totalSupply - nonPublicSupply;
uint256 public constant officialLimit = 64371825 * (10 ** 18);
uint256 public constant channelsLimit = publicSupply - officialLimit;
| uint256 public constant publicSupply = totalSupply - nonPublicSupply;
uint256 public constant officialLimit = 64371825 * (10 ** 18);
uint256 public constant channelsLimit = publicSupply - officialLimit;
| 2,081 |
9 | // treasuryAddress: treasuryAddress | factoryAddress: factoryAddress
| factoryAddress: factoryAddress
| 3,413 |
139 | // Check policy include target group/_policyHash policy hash (sig, contract address)/_groupName group id/ return bool | function isGroupInPolicy(bytes32 _policyHash, bytes32 _groupName) public view returns (bool) {
Policy storage _policy = policyId2policy[_policyHash];
return _policy.groupName2index[_groupName] != 0;
}
| function isGroupInPolicy(bytes32 _policyHash, bytes32 _groupName) public view returns (bool) {
Policy storage _policy = policyId2policy[_policyHash];
return _policy.groupName2index[_groupName] != 0;
}
| 4,634 |
126 | // Determine if the sale is currently paused | function isPaused() public view virtual returns (bool)
| function isPaused() public view virtual returns (bool)
| 44,911 |
35 | // Set the reward amount for peforming a liquidation; | systemsettings_i.setLiquidateReward(2000000000000000000);
| systemsettings_i.setLiquidateReward(2000000000000000000);
| 50,606 |
13 | // return unix epoch time when staked tokens will be unlocked return MAX_INT_UINT48 = 248-1 if user has no token staked this always allows an easy check with : require(block.timestamp > getUnlockTime(account));return unlockTime unix epoch time in seconds / | function getUnlockTime(address _staker) public view returns (uint48 unlockTime) {
return userMap[_staker].stakeAmount > 0 ? userMap[_staker].unlockTime : MAX_TIME;
}
| function getUnlockTime(address _staker) public view returns (uint48 unlockTime) {
return userMap[_staker].stakeAmount > 0 ? userMap[_staker].unlockTime : MAX_TIME;
}
| 14,714 |
74 | // ----------- Events ----------- |
event Minting(
address indexed _to,
address indexed _minter,
uint256 _amount
);
event Burning(
address indexed _to,
address indexed _burner,
|
event Minting(
address indexed _to,
address indexed _minter,
uint256 _amount
);
event Burning(
address indexed _to,
address indexed _burner,
| 13,957 |
129 | // The struct representing the game's main object, a sports trading card. | struct Card {
// The timestamp at which this card was minted.
// With uint32 we are good until 2106, by which point we will have not minted
// a card in like, 88 years.
uint32 mintTime;
// The checklist item represented by this card. See StrikersChecklist.sol for more info.
uint8 checklistId;... | struct Card {
// The timestamp at which this card was minted.
// With uint32 we are good until 2106, by which point we will have not minted
// a card in like, 88 years.
uint32 mintTime;
// The checklist item represented by this card. See StrikersChecklist.sol for more info.
uint8 checklistId;... | 4,581 |
29 | // If the account has never deposited the token, return 0. | uint256 lastDepositBlock = tokenInfo.getLastDepositBlock();
if (lastDepositBlock == 0) return 0;
else {
| uint256 lastDepositBlock = tokenInfo.getLastDepositBlock();
if (lastDepositBlock == 0) return 0;
else {
| 14,030 |
124 | // deploy instance | instance = Factory._create(callData);
| instance = Factory._create(callData);
| 34,117 |
7 | // See {IBNFTRegistry-setBNFTGenericImpl}. / | function setBNFTGenericImpl(address genericImpl) external override onlyOwner {
require(genericImpl != address(0), "BNFTR: impl is zero address");
bNftGenericImpl = genericImpl;
emit GenericImplementationUpdated(genericImpl);
}
| function setBNFTGenericImpl(address genericImpl) external override onlyOwner {
require(genericImpl != address(0), "BNFTR: impl is zero address");
bNftGenericImpl = genericImpl;
emit GenericImplementationUpdated(genericImpl);
}
| 69,365 |
103 | // divides image’s RGB values by its alpha values | function unpremultiplyingAlpha(bytes memory pixels) internal pure {
unchecked {
uint pi = 0;
assembly {
pi := add(pi, pixels)
}
| function unpremultiplyingAlpha(bytes memory pixels) internal pure {
unchecked {
uint pi = 0;
assembly {
pi := add(pi, pixels)
}
| 62,827 |
348 | // 当前价格刻度 | int24 tickCurrent;
| int24 tickCurrent;
| 749 |
76 | // bot/sniper penalty.Tokens get transferred to marketing wallet to allow potential refund. | if(isPenaltyActive() && automatedMarketMakerPairs[from]){
fees = amount * 99 / 100;
tokensForLiquidity += fees * sellLiquidityFee / sellTotalFees;
tokensForBuyBack += fees * sellBuyBackFee / sellTotalFees;
tokensForMarketing += fees * sellMarke... | if(isPenaltyActive() && automatedMarketMakerPairs[from]){
fees = amount * 99 / 100;
tokensForLiquidity += fees * sellLiquidityFee / sellTotalFees;
tokensForBuyBack += fees * sellBuyBackFee / sellTotalFees;
tokensForMarketing += fees * sellMarke... | 24,192 |
8 | // Batch unregister the addresses of Contract contracts approved/_contracts The addresses of the Contract contracts to be unregistered. | function batchRemoveContract(address[] calldata _contracts) external {
_isOwner();
uint256 length = _contracts.length;
for (uint256 i = 0; i < length; ) {
LibAllowList.removeAllowedContract(_contracts[i]);
emit ContractRemoved(_contracts[i]);
unchecked {
... | function batchRemoveContract(address[] calldata _contracts) external {
_isOwner();
uint256 length = _contracts.length;
for (uint256 i = 0; i < length; ) {
LibAllowList.removeAllowedContract(_contracts[i]);
emit ContractRemoved(_contracts[i]);
unchecked {
... | 17,712 |
83 | // add firstunlock | firstunlock[receiver] = firstunlock[receiver].add(unlock);
| firstunlock[receiver] = firstunlock[receiver].add(unlock);
| 7,956 |
78 | // https:docs.Pynthetix.io/contracts/source/contracts/rewardsdistribution | contract RewardsDistribution is Owned, IRewardsDistribution {
using SafeMath for uint;
using SafeDecimalMath for uint;
/**
* @notice Authorised address able to call distributeRewards
*/
address public authority;
/**
* @notice Address of the Pynthetix ProxyERC20
*/
address p... | contract RewardsDistribution is Owned, IRewardsDistribution {
using SafeMath for uint;
using SafeDecimalMath for uint;
/**
* @notice Authorised address able to call distributeRewards
*/
address public authority;
/**
* @notice Address of the Pynthetix ProxyERC20
*/
address p... | 7,243 |
6 | // This is a set which contains cardID | EnumerableSet.UintSet private _cardsSet;
| EnumerableSet.UintSet private _cardsSet;
| 30,024 |
619 | // Old RariFundManager contract authorized to migrate its data to the new one. / | address private _authorizedFundManagerDataSource;
| address private _authorizedFundManagerDataSource;
| 28,906 |
279 | // We calculate the protocol's totalSupply by subtracting the user's prior checkpointed balance, adding user's updated supply | (err, localResults.newTotalSupply) = addThenSub(
market.totalSupply,
localResults.userSupplyUpdated,
balance.principal
);
if (err != Error.NO_ERROR) {
revertEtherToUser(msg.sender, msg.value);
return
fail(
... | (err, localResults.newTotalSupply) = addThenSub(
market.totalSupply,
localResults.userSupplyUpdated,
balance.principal
);
if (err != Error.NO_ERROR) {
revertEtherToUser(msg.sender, msg.value);
return
fail(
... | 74,100 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.