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 |
|---|---|---|---|---|
111 | // Address which owns this proxy. // Associated registry with contract authentication information. // Whether access has been revoked. // Delegate call could be used to atomically transfer multiple assets owned by the proxy contract with one order. / | enum HowToCall { Call, DelegateCall }
/* Event fired when the proxy access is revoked or unrevoked. */
event Revoked(bool revoked);
/**
* Create an AuthenticatedProxy
*
* @param addrUser Address of user on whose behalf this proxy will act
* @param addrRegistry Address of ProxyRegistry contract which will manage this proxy
*/
function AuthenticatedProxy(address addrUser, ProxyRegistry addrRegistry) public {
user = addrUser;
registry = addrRegistry;
}
| enum HowToCall { Call, DelegateCall }
/* Event fired when the proxy access is revoked or unrevoked. */
event Revoked(bool revoked);
/**
* Create an AuthenticatedProxy
*
* @param addrUser Address of user on whose behalf this proxy will act
* @param addrRegistry Address of ProxyRegistry contract which will manage this proxy
*/
function AuthenticatedProxy(address addrUser, ProxyRegistry addrRegistry) public {
user = addrUser;
registry = addrRegistry;
}
| 65,099 |
334 | // 获取某个头寸,以基金本币衡量的所有资产/pool 交易池索引号/token 头寸索引号/ return amount 资产数量 | function assets(
Info storage self,
address pool,
address token,
mapping(address => bytes) storage sellPath,
address uniV3Factory
| function assets(
Info storage self,
address pool,
address token,
mapping(address => bytes) storage sellPath,
address uniV3Factory
| 7,098 |
4 | // prices - replace it with yours | uint256 public price = 0.09 ether;
| uint256 public price = 0.09 ether;
| 2,697 |
19 | // Counts the number of leading bits two bytes32 have in common/data1: The first piece of data to compare/data2: The second piece of data to compare/ return The number of shared leading bits solhint-disable-next-line func-visibility | function countCommonPrefix(bytes32 data1, bytes32 data2) pure returns (uint256) {
uint256 count = 0;
for (uint256 i = 0; i < Constants.MAX_HEIGHT; i++) {
if (getBitAtFromMSB(data1, i) == getBitAtFromMSB(data2, i)) {
count += 1;
} else {
break;
}
}
return count;
}
| function countCommonPrefix(bytes32 data1, bytes32 data2) pure returns (uint256) {
uint256 count = 0;
for (uint256 i = 0; i < Constants.MAX_HEIGHT; i++) {
if (getBitAtFromMSB(data1, i) == getBitAtFromMSB(data2, i)) {
count += 1;
} else {
break;
}
}
return count;
}
| 39,021 |
24 | // validate the sequence | require(sequence > 0);
| require(sequence > 0);
| 15,725 |
367 | // Stores high level basket info | struct Basket {
// Array of Bassets currently active
Basset[] bassets;
// Max number of bAssets that can be present in any Basket
uint8 maxBassets;
// Some bAsset is undergoing re-collateralisation
bool undergoingRecol;
//
// In the event that we do not raise enough funds from the auctioning of a failed Basset,
// The Basket is deemed as failed, and is undercollateralised to a certain degree.
// The collateralisation ratio is used to calc Masset burn rate.
bool failed;
uint256 collateralisationRatio;
}
| struct Basket {
// Array of Bassets currently active
Basset[] bassets;
// Max number of bAssets that can be present in any Basket
uint8 maxBassets;
// Some bAsset is undergoing re-collateralisation
bool undergoingRecol;
//
// In the event that we do not raise enough funds from the auctioning of a failed Basset,
// The Basket is deemed as failed, and is undercollateralised to a certain degree.
// The collateralisation ratio is used to calc Masset burn rate.
bool failed;
uint256 collateralisationRatio;
}
| 44,886 |
151 | // Update schedule[n - 1].totalSupplyMinted | if (lastPeriodAmount > 0) {
schedules[currentIndex - 1].totalSupplyMinted = schedules[currentIndex - 1].totalSupplyMinted.add(lastPeriodAmount);
}
| if (lastPeriodAmount > 0) {
schedules[currentIndex - 1].totalSupplyMinted = schedules[currentIndex - 1].totalSupplyMinted.add(lastPeriodAmount);
}
| 25,411 |
60 | // amount of KBRF user ordered | mapping(address => uint256) public balances;
mapping(address => uint256) public ethBalances;
mapping(address => bool) public claimed;
| mapping(address => uint256) public balances;
mapping(address => uint256) public ethBalances;
mapping(address => bool) public claimed;
| 29,065 |
5 | // Receive all sent funds without any further logic | function () public payable {}
// @dev Withdraw function sends all the funds to the wallet if conditions are correct
function withdraw() public {
if (msg.sender != multisig) throw; // Only the multisig can request it
if (block.number > finalBlock) return doWithdraw(); // Allow after the final block
if (tokenSale.saleFinalized()) return doWithdraw(); // Allow when sale is finalized
}
| function () public payable {}
// @dev Withdraw function sends all the funds to the wallet if conditions are correct
function withdraw() public {
if (msg.sender != multisig) throw; // Only the multisig can request it
if (block.number > finalBlock) return doWithdraw(); // Allow after the final block
if (tokenSale.saleFinalized()) return doWithdraw(); // Allow when sale is finalized
}
| 30,013 |
20 | // Originally, in Withdraw even address of the token is an address of the corresponding root token. In case of Augur it is an address of the token itself. Predicate knows root Cash contract | (uint256 exitAmount, uint256 age, , address maticCash) = abi.decode(
_preState,
(uint256, uint256, address, address)
);
RLPReader.RLPItem[] memory log = ProofReader.getLog(
ProofReader.convertToExitPayload(data)
);
exitAmount = BytesLib.toUint(log[2].toBytes(), 0);
| (uint256 exitAmount, uint256 age, , address maticCash) = abi.decode(
_preState,
(uint256, uint256, address, address)
);
RLPReader.RLPItem[] memory log = ProofReader.getLog(
ProofReader.convertToExitPayload(data)
);
exitAmount = BytesLib.toUint(log[2].toBytes(), 0);
| 51,634 |
19 | // constructor() public { | function initialize(address _admin ) public initializer {
| function initialize(address _admin ) public initializer {
| 44,761 |
29 | // diamond members get 10% extra bonus tokens from people they invited,until those become diamond members themselves | uint256 constant DIAMOND_MEMBER_INTRODUCER_BONUS_TOKENS_PER_THOUSAND = 100;
| uint256 constant DIAMOND_MEMBER_INTRODUCER_BONUS_TOKENS_PER_THOUSAND = 100;
| 38,932 |
127 | // Modifier to only allow the execution of owner payout when winner is determined | modifier canPayOwners() {
require (!canceled && winningOption != 2 && completed && !ownersPayed && now > BETTING_CLOSES);
_;
}
| modifier canPayOwners() {
require (!canceled && winningOption != 2 && completed && !ownersPayed && now > BETTING_CLOSES);
_;
}
| 5,306 |
126 | // Update a borrower's balance to it's adjusted amount. _user The address to be updated. / | {
Balance memory balance = balances[_user];
// The new balance that a user will have.
uint256 newBalance = balanceOf(_user);
// newBalance should never be greater than last balance.
uint256 loss = balance.lastBalance.sub(newBalance);
_payPercents(_user, uint128(loss));
// Update storage balance.
balance.lastBalance = uint128(newBalance);
balance.lastTime = uint64(block.timestamp);
emit Loss(_user, loss);
if (newBalance == 0) {
_priceChange(_user, 0);
}
balances[_user] = balance;
}
| {
Balance memory balance = balances[_user];
// The new balance that a user will have.
uint256 newBalance = balanceOf(_user);
// newBalance should never be greater than last balance.
uint256 loss = balance.lastBalance.sub(newBalance);
_payPercents(_user, uint128(loss));
// Update storage balance.
balance.lastBalance = uint128(newBalance);
balance.lastTime = uint64(block.timestamp);
emit Loss(_user, loss);
if (newBalance == 0) {
_priceChange(_user, 0);
}
balances[_user] = balance;
}
| 30,302 |
68 | // Deletes the specified vesting schedule allocation./Please note that this action can only be performed by an administrator./ _address The address of the beneficiary whose allocation is being requested to be deleted./return Returns true if the vesting schedule allocation was successfully deleted. | function deleteAllocation(address _address) external onlyAdmin returns(bool) {
require(_address != address(0), "Invalid address.");
require(allocations[_address].startedOn > 0, "Access is denied. Requested vesting schedule does not exist.");
require(!allocations[_address].deleted, "Access is denied. Requested vesting schedule does not exist.");
uint256 allocation = allocations[_address].allocation;
uint256 previousBalance = allocations[_address].closingBalance;
uint256 withdrawn = allocations[_address].withdrawn;
uint256 lessAmount = previousBalance.sub(withdrawn);
allocations[_address].allocation = allocation.sub(lessAmount);
allocations[_address].closingBalance = 0;
allocations[_address].deleted = true;
totalVested = totalVested.sub(lessAmount);
emit AllocationDeleted(_address, allocations[_address].memberName, lessAmount);
return true;
}
| function deleteAllocation(address _address) external onlyAdmin returns(bool) {
require(_address != address(0), "Invalid address.");
require(allocations[_address].startedOn > 0, "Access is denied. Requested vesting schedule does not exist.");
require(!allocations[_address].deleted, "Access is denied. Requested vesting schedule does not exist.");
uint256 allocation = allocations[_address].allocation;
uint256 previousBalance = allocations[_address].closingBalance;
uint256 withdrawn = allocations[_address].withdrawn;
uint256 lessAmount = previousBalance.sub(withdrawn);
allocations[_address].allocation = allocation.sub(lessAmount);
allocations[_address].closingBalance = 0;
allocations[_address].deleted = true;
totalVested = totalVested.sub(lessAmount);
emit AllocationDeleted(_address, allocations[_address].memberName, lessAmount);
return true;
}
| 48,948 |
48 | // The minimum amount needed to place bet (in Wei) Can be changed later by the changeMinimumBetAmount() function / | uint public minimumBetAmount = 1000000000;
| uint public minimumBetAmount = 1000000000;
| 2,800 |
4 | // taking ideas from FirstBlood token / | contract SafeMath {
/* function assert(bool assertion) internal { */
/* if (!assertion) { */
/* throw; */
/* } */
/* } // assert no longer needed once solidity is on 0.4.10 */
function safeAdd(uint256 x, uint256 y) internal pure returns(uint256) {
uint256 z = x + y;
assert((z >= x) && (z >= y));
return z;
}
function safeSubtract(uint256 x, uint256 y) internal pure returns(uint256) {
assert(x >= y);
uint256 z = x - y;
return z;
}
function safeMult(uint256 x, uint256 y) internal pure returns(uint256) {
uint256 z = x * y;
assert((x == 0)||(z/x == y));
return z;
}
}
| contract SafeMath {
/* function assert(bool assertion) internal { */
/* if (!assertion) { */
/* throw; */
/* } */
/* } // assert no longer needed once solidity is on 0.4.10 */
function safeAdd(uint256 x, uint256 y) internal pure returns(uint256) {
uint256 z = x + y;
assert((z >= x) && (z >= y));
return z;
}
function safeSubtract(uint256 x, uint256 y) internal pure returns(uint256) {
assert(x >= y);
uint256 z = x - y;
return z;
}
function safeMult(uint256 x, uint256 y) internal pure returns(uint256) {
uint256 z = x * y;
assert((x == 0)||(z/x == y));
return z;
}
}
| 1,873 |
98 | // check if the input is enough for the desired transfer | if (exchange_addr == DEFAULT_ADDRESS) {
require(msg.value == input_total, 'No enough ether.');
} else {
| if (exchange_addr == DEFAULT_ADDRESS) {
require(msg.value == input_total, 'No enough ether.');
} else {
| 4,932 |
130 | // if we did find a nearby active offer Walk the order book down from there... | if (_isPricedLtOrEq(id, pos)) {
uint256 old_pos;
| if (_isPricedLtOrEq(id, pos)) {
uint256 old_pos;
| 8,584 |
38 | // Otherwise just naively try to find the winner (will work until mass amounts of players) | for (uint256 i = 0; i < rafflePlayers[raffleRareId].length; i++) {
address player = rafflePlayers[raffleRareId][i];
TicketPurchases storage playersTickets = ticketsBoughtByPlayer[player];
uint256 endIndex = playersTickets.numPurchases - 1;
| for (uint256 i = 0; i < rafflePlayers[raffleRareId].length; i++) {
address player = rafflePlayers[raffleRareId][i];
TicketPurchases storage playersTickets = ticketsBoughtByPlayer[player];
uint256 endIndex = playersTickets.numPurchases - 1;
| 51,251 |
10 | // DittoRouter struct for robust partially-fillable complex swaps with tokens bought and sold in one transaction nftToTokenTrades array of trade info where you are selling Nfts into pools tokenToNftTrades array of trade info where you are buying Nfts out of pools inputAmount The total amount of tokens you are willing to spend on the Nfts you buy tokenRecipient The address to send the tokens to after the swap nftRecipient The address to send the Nfts to after the swap / | struct RobustComplexSwap {
RobustSwap[] tokenToNftTrades;
RobustNftInSwap[] nftToTokenTrades;
uint256 inputAmount;
address tokenRecipient;
address nftRecipient;
uint256 deadline;
}
| struct RobustComplexSwap {
RobustSwap[] tokenToNftTrades;
RobustNftInSwap[] nftToTokenTrades;
uint256 inputAmount;
address tokenRecipient;
address nftRecipient;
uint256 deadline;
}
| 30,478 |
96 | // Check if address is admin | function isAdmin(address check) public view returns (bool){
return admins[check] == true;
}
| function isAdmin(address check) public view returns (bool){
return admins[check] == true;
}
| 15,686 |
187 | // return comma separated traits in order: hat, fur, clothes, eyes, earring, mouth, background | function getAttributes(uint256 tokenId) public view returns (string memory) {
Ape memory ape = randomOne(tokenId);
string memory o=string(abi.encodePacked(uint256(ape.hat).toString(),co1,uint256(ape.fur).toString(),co1,uint256(ape.clothes).toString(),co1));
return string(abi.encodePacked(o,uint256(ape.eyes).toString(),co1,uint256(ape.earring).toString(),co1,uint256(ape.mouth).toString(),co1,uint256(ape.bg).toString()));
}
| function getAttributes(uint256 tokenId) public view returns (string memory) {
Ape memory ape = randomOne(tokenId);
string memory o=string(abi.encodePacked(uint256(ape.hat).toString(),co1,uint256(ape.fur).toString(),co1,uint256(ape.clothes).toString(),co1));
return string(abi.encodePacked(o,uint256(ape.eyes).toString(),co1,uint256(ape.earring).toString(),co1,uint256(ape.mouth).toString(),co1,uint256(ape.bg).toString()));
}
| 78,379 |
188 | // Check if pre sale is not active | require(countdowns[_wave] < now);
for (uint256 i = 0; i < waveToTokens[_wave].length; i++) {
uint256 tokenId = waveToTokens[_wave][i];
| require(countdowns[_wave] < now);
for (uint256 i = 0; i < waveToTokens[_wave].length; i++) {
uint256 tokenId = waveToTokens[_wave][i];
| 6,961 |
2 | // -------------------------------------------------------------------------- // Constructor// -------------------------------------------------------------------------- // Constructs the ERC20 token contract _tokenName Name of the token _tokenSymbol Token symbol _tokenDecimals Number of decimals for token / |
constructor(string memory _tokenName, string memory _tokenSymbol, uint8 _tokenDecimals)
BaseControlledMintableBurnableERC20(_tokenName, _tokenSymbol, _tokenDecimals)
|
constructor(string memory _tokenName, string memory _tokenSymbol, uint8 _tokenDecimals)
BaseControlledMintableBurnableERC20(_tokenName, _tokenSymbol, _tokenDecimals)
| 21,760 |
237 | // Check if farming is started | function _checkFarming() internal {
require(farmingStartTimestamp <= block.timestamp, 'Farming has not yet started. Try again later.');
if (!farmingStarted) {
farmingStarted = true;
halvingTimestamp = block.timestamp.add(HALVING_DURATION);
lastUpdateTimestamp = block.timestamp;
}
}
| function _checkFarming() internal {
require(farmingStartTimestamp <= block.timestamp, 'Farming has not yet started. Try again later.');
if (!farmingStarted) {
farmingStarted = true;
halvingTimestamp = block.timestamp.add(HALVING_DURATION);
lastUpdateTimestamp = block.timestamp;
}
}
| 31,276 |
155 | // В. Родзянко успокаивал их.^^^^^^^^^^^ | recognition В_Родзянко language=Russian
| recognition В_Родзянко language=Russian
| 29,111 |
81 | // Check whether the buyer is allowed to purchase this amount of cover. Used because core can only buy 30%, and 35% for shields. _protocol The protocol cover is being purchased for./ | {
uint256 totalAllowed = IStakeManager(getModule("STAKE")).totalStakedAmount(_protocol);
uint256 shield = arShields[msg.sender];
if (shield == 1) {
uint256 currentCover = arShieldCover[_protocol];
uint256 allowed = totalAllowed * arShieldPercent / DENOMINATOR;
return (shield, allowed > currentCover ? allowed - currentCover : 0);
} else if (shield == 2) {
uint256 currentCover = arShieldPlusCover[_protocol];
uint256 allowed = totalAllowed * arShieldPlusPercent / DENOMINATOR;
return (shield, allowed > currentCover ? allowed - currentCover : 0);
} else {
uint256 currentCover = coreCover[_protocol];
uint256 allowed = totalAllowed * corePercent / DENOMINATOR;
return (shield, allowed > currentCover ? allowed - currentCover : 0);
}
}
| {
uint256 totalAllowed = IStakeManager(getModule("STAKE")).totalStakedAmount(_protocol);
uint256 shield = arShields[msg.sender];
if (shield == 1) {
uint256 currentCover = arShieldCover[_protocol];
uint256 allowed = totalAllowed * arShieldPercent / DENOMINATOR;
return (shield, allowed > currentCover ? allowed - currentCover : 0);
} else if (shield == 2) {
uint256 currentCover = arShieldPlusCover[_protocol];
uint256 allowed = totalAllowed * arShieldPlusPercent / DENOMINATOR;
return (shield, allowed > currentCover ? allowed - currentCover : 0);
} else {
uint256 currentCover = coreCover[_protocol];
uint256 allowed = totalAllowed * corePercent / DENOMINATOR;
return (shield, allowed > currentCover ? allowed - currentCover : 0);
}
}
| 27,363 |
7 | // List of all deposits by each investor Implemented to enable quick access to investor deposits even without server caching | mapping(address => mapping(uint64 => uint64)) public investorsToDeposit;
| mapping(address => mapping(uint64 => uint64)) public investorsToDeposit;
| 24,364 |
53 | // i.e. if this was an existing reputation, then require that the ID hasn't changed. | require(_agreeStateReputationUID == _disagreeStateReputationUID, "colony-reputation-mining-uid-changed-for-existing-reputation");
emit ProveUIDSuccess(_agreeStateReputationUID, _disagreeStateReputationUID, true);
| require(_agreeStateReputationUID == _disagreeStateReputationUID, "colony-reputation-mining-uid-changed-for-existing-reputation");
emit ProveUIDSuccess(_agreeStateReputationUID, _disagreeStateReputationUID, true);
| 23,643 |
10 | // manual claim | uint256 internal _stashedForManualClaims;
mapping(address => uint256) internal _manualClaims; // address => amount
| uint256 internal _stashedForManualClaims;
mapping(address => uint256) internal _manualClaims; // address => amount
| 8,482 |
8 | // Returns whether address `who` is auth'ed./ @custom:deprecated Use `authed(address)(bool)` instead./who The address to check./ return 1 if `who` is auth'ed, 0 otherwise. | function wards(address who) external view returns (uint);
| function wards(address who) external view returns (uint);
| 28,404 |
518 | // Update the given pool's ability to withdraw tokens Note contract owner is meant to be a governance contract allowing CORE governance consensus | function toggleWithdrawals(bool _withdrawable) public onlyOwner {
fannyPoolInfo.withdrawable = _withdrawable;
}
| function toggleWithdrawals(bool _withdrawable) public onlyOwner {
fannyPoolInfo.withdrawable = _withdrawable;
}
| 8,987 |
12 | // Array for storing all vesting stages with structure defined above. / | VestingStage[4] public stages;
| VestingStage[4] public stages;
| 54,383 |
1 | // hash of energy offer (processed by energy agent) mapped to offer | mapping (bytes32 => offer) public offers;
event bought(bytes32 trans, address payable buyer);
event confirmed(bytes32 trans, address payable buyer);
| mapping (bytes32 => offer) public offers;
event bought(bytes32 trans, address payable buyer);
event confirmed(bytes32 trans, address payable buyer);
| 41,747 |
47 | // Store x squared. | let xx := mul(x, x)
| let xx := mul(x, x)
| 8,632 |
18 | // Administration Functions / | function empty(address _sendTo) public onlyRoot { if(!_sendTo.send(address(this).balance)) revert(); }
function kill() public onlyRoot { selfdestruct(root); }
function transferRoot(address _newOwner) public onlyRoot { root = _newOwner; }
}
| function empty(address _sendTo) public onlyRoot { if(!_sendTo.send(address(this).balance)) revert(); }
function kill() public onlyRoot { selfdestruct(root); }
function transferRoot(address _newOwner) public onlyRoot { root = _newOwner; }
}
| 31,499 |
6 | // Returns the address of the Authorizer adaptor contract. / | function getAuthorizerAdaptor() external view returns (IAuthorizerAdaptor) {
return _authorizerAdaptor;
}
| function getAuthorizerAdaptor() external view returns (IAuthorizerAdaptor) {
return _authorizerAdaptor;
}
| 22,829 |
1,112 | // handler function required by MsgReceiverApp | function executeMessage(
address _sender,
uint64 _srcChainId,
bytes memory _message,
address // executor
| function executeMessage(
address _sender,
uint64 _srcChainId,
bytes memory _message,
address // executor
| 5,502 |
195 | // TapToken with Governance. | contract TapToken is BEP20("TapSwap Token", "TAP") {
/// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef).
function mint(address _to, uint256 _amount) public onlyOperator {
_mint(_to, _amount);
_moveDelegates(address(0), _delegates[_to], _amount);
}
// Copied and modified from YAM code:
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol
// Which is copied and modified from COMPOUND:
// https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol
/// @dev A record of each accounts delegate
mapping (address => address) internal _delegates;
/// @notice A checkpoint for marking number of votes from a given block
struct Checkpoint {
uint32 fromBlock;
uint256 votes;
}
/// @notice A record of votes checkpoints for each account, by index
mapping (address => mapping (uint32 => Checkpoint)) public checkpoints;
/// @notice The number of checkpoints for each account
mapping (address => uint32) public numCheckpoints;
/// @notice The EIP-712 typehash for the contract's domain
bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");
/// @notice The EIP-712 typehash for the delegation struct used by the contract
bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
/// @notice A record of states for signing / validating signatures
mapping (address => uint) public nonces;
/// @notice An event thats emitted when an account changes its delegate
event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);
/// @notice An event thats emitted when a delegate account's vote balance changes
event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance);
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegator The address to get delegatee for
*/
function delegates(address delegator)
external
view
returns (address)
{
return _delegates[delegator];
}
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegatee The address to delegate votes to
*/
function delegate(address delegatee) external {
return _delegate(msg.sender, delegatee);
}
/**
* @notice Delegates votes from signatory to `delegatee`
* @param delegatee The address to delegate votes to
* @param nonce The contract state required to match the signature
* @param expiry The time at which to expire the signature
* @param v The recovery byte of the signature
* @param r Half of the ECDSA signature pair
* @param s Half of the ECDSA signature pair
*/
function delegateBySig(
address delegatee,
uint nonce,
uint expiry,
uint8 v,
bytes32 r,
bytes32 s
)
external
{
bytes32 domainSeparator = keccak256(
abi.encode(
DOMAIN_TYPEHASH,
keccak256(bytes(name())),
getChainId(),
address(this)
)
);
bytes32 structHash = keccak256(
abi.encode(
DELEGATION_TYPEHASH,
delegatee,
nonce,
expiry
)
);
bytes32 digest = keccak256(
abi.encodePacked(
"\x19\x01",
domainSeparator,
structHash
)
);
address signatory = ecrecover(digest, v, r, s);
require(signatory != address(0), "TAP::delegateBySig: invalid signature");
require(nonce == nonces[signatory]++, "TAP::delegateBySig: invalid nonce");
require(now <= expiry, "TAP::delegateBySig: signature expired");
return _delegate(signatory, delegatee);
}
/**
* @notice Gets the current votes balance for `account`
* @param account The address to get votes balance
* @return The number of current votes for `account`
*/
function getCurrentVotes(address account)
external
view
returns (uint256)
{
uint32 nCheckpoints = numCheckpoints[account];
return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;
}
/**
* @notice Determine the prior number of votes for an account as of a block number
* @dev Block number must be a finalized block or else this function will revert to prevent misinformation.
* @param account The address of the account to check
* @param blockNumber The block number to get the vote balance at
* @return The number of votes the account had as of the given block
*/
function getPriorVotes(address account, uint blockNumber)
external
view
returns (uint256)
{
require(blockNumber < block.number, "TAP::getPriorVotes: not yet determined");
uint32 nCheckpoints = numCheckpoints[account];
if (nCheckpoints == 0) {
return 0;
}
// First check most recent balance
if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {
return checkpoints[account][nCheckpoints - 1].votes;
}
// Next check implicit zero balance
if (checkpoints[account][0].fromBlock > blockNumber) {
return 0;
}
uint32 lower = 0;
uint32 upper = nCheckpoints - 1;
while (upper > lower) {
uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow
Checkpoint memory cp = checkpoints[account][center];
if (cp.fromBlock == blockNumber) {
return cp.votes;
} else if (cp.fromBlock < blockNumber) {
lower = center;
} else {
upper = center - 1;
}
}
return checkpoints[account][lower].votes;
}
function _delegate(address delegator, address delegatee)
internal
{
address currentDelegate = _delegates[delegator];
uint256 delegatorBalance = balanceOf(delegator); // balance of underlying TAPs (not scaled);
_delegates[delegator] = delegatee;
emit DelegateChanged(delegator, currentDelegate, delegatee);
_moveDelegates(currentDelegate, delegatee, delegatorBalance);
}
function _moveDelegates(address srcRep, address dstRep, uint256 amount) internal {
if (srcRep != dstRep && amount > 0) {
if (srcRep != address(0)) {
// decrease old representative
uint32 srcRepNum = numCheckpoints[srcRep];
uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;
uint256 srcRepNew = srcRepOld.sub(amount);
_writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);
}
if (dstRep != address(0)) {
// increase new representative
uint32 dstRepNum = numCheckpoints[dstRep];
uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;
uint256 dstRepNew = dstRepOld.add(amount);
_writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);
}
}
}
function _writeCheckpoint(
address delegatee,
uint32 nCheckpoints,
uint256 oldVotes,
uint256 newVotes
)
internal
{
uint32 blockNumber = safe32(block.number, "TAP::_writeCheckpoint: block number exceeds 32 bits");
if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) {
checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;
} else {
checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes);
numCheckpoints[delegatee] = nCheckpoints + 1;
}
emit DelegateVotesChanged(delegatee, oldVotes, newVotes);
}
function safe32(uint n, string memory errorMessage) internal pure returns (uint32) {
require(n < 2**32, errorMessage);
return uint32(n);
}
function getChainId() internal pure returns (uint) {
uint256 chainId;
assembly { chainId := chainid() }
return chainId;
}
} | contract TapToken is BEP20("TapSwap Token", "TAP") {
/// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef).
function mint(address _to, uint256 _amount) public onlyOperator {
_mint(_to, _amount);
_moveDelegates(address(0), _delegates[_to], _amount);
}
// Copied and modified from YAM code:
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol
// Which is copied and modified from COMPOUND:
// https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol
/// @dev A record of each accounts delegate
mapping (address => address) internal _delegates;
/// @notice A checkpoint for marking number of votes from a given block
struct Checkpoint {
uint32 fromBlock;
uint256 votes;
}
/// @notice A record of votes checkpoints for each account, by index
mapping (address => mapping (uint32 => Checkpoint)) public checkpoints;
/// @notice The number of checkpoints for each account
mapping (address => uint32) public numCheckpoints;
/// @notice The EIP-712 typehash for the contract's domain
bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");
/// @notice The EIP-712 typehash for the delegation struct used by the contract
bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
/// @notice A record of states for signing / validating signatures
mapping (address => uint) public nonces;
/// @notice An event thats emitted when an account changes its delegate
event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);
/// @notice An event thats emitted when a delegate account's vote balance changes
event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance);
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegator The address to get delegatee for
*/
function delegates(address delegator)
external
view
returns (address)
{
return _delegates[delegator];
}
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegatee The address to delegate votes to
*/
function delegate(address delegatee) external {
return _delegate(msg.sender, delegatee);
}
/**
* @notice Delegates votes from signatory to `delegatee`
* @param delegatee The address to delegate votes to
* @param nonce The contract state required to match the signature
* @param expiry The time at which to expire the signature
* @param v The recovery byte of the signature
* @param r Half of the ECDSA signature pair
* @param s Half of the ECDSA signature pair
*/
function delegateBySig(
address delegatee,
uint nonce,
uint expiry,
uint8 v,
bytes32 r,
bytes32 s
)
external
{
bytes32 domainSeparator = keccak256(
abi.encode(
DOMAIN_TYPEHASH,
keccak256(bytes(name())),
getChainId(),
address(this)
)
);
bytes32 structHash = keccak256(
abi.encode(
DELEGATION_TYPEHASH,
delegatee,
nonce,
expiry
)
);
bytes32 digest = keccak256(
abi.encodePacked(
"\x19\x01",
domainSeparator,
structHash
)
);
address signatory = ecrecover(digest, v, r, s);
require(signatory != address(0), "TAP::delegateBySig: invalid signature");
require(nonce == nonces[signatory]++, "TAP::delegateBySig: invalid nonce");
require(now <= expiry, "TAP::delegateBySig: signature expired");
return _delegate(signatory, delegatee);
}
/**
* @notice Gets the current votes balance for `account`
* @param account The address to get votes balance
* @return The number of current votes for `account`
*/
function getCurrentVotes(address account)
external
view
returns (uint256)
{
uint32 nCheckpoints = numCheckpoints[account];
return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;
}
/**
* @notice Determine the prior number of votes for an account as of a block number
* @dev Block number must be a finalized block or else this function will revert to prevent misinformation.
* @param account The address of the account to check
* @param blockNumber The block number to get the vote balance at
* @return The number of votes the account had as of the given block
*/
function getPriorVotes(address account, uint blockNumber)
external
view
returns (uint256)
{
require(blockNumber < block.number, "TAP::getPriorVotes: not yet determined");
uint32 nCheckpoints = numCheckpoints[account];
if (nCheckpoints == 0) {
return 0;
}
// First check most recent balance
if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {
return checkpoints[account][nCheckpoints - 1].votes;
}
// Next check implicit zero balance
if (checkpoints[account][0].fromBlock > blockNumber) {
return 0;
}
uint32 lower = 0;
uint32 upper = nCheckpoints - 1;
while (upper > lower) {
uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow
Checkpoint memory cp = checkpoints[account][center];
if (cp.fromBlock == blockNumber) {
return cp.votes;
} else if (cp.fromBlock < blockNumber) {
lower = center;
} else {
upper = center - 1;
}
}
return checkpoints[account][lower].votes;
}
function _delegate(address delegator, address delegatee)
internal
{
address currentDelegate = _delegates[delegator];
uint256 delegatorBalance = balanceOf(delegator); // balance of underlying TAPs (not scaled);
_delegates[delegator] = delegatee;
emit DelegateChanged(delegator, currentDelegate, delegatee);
_moveDelegates(currentDelegate, delegatee, delegatorBalance);
}
function _moveDelegates(address srcRep, address dstRep, uint256 amount) internal {
if (srcRep != dstRep && amount > 0) {
if (srcRep != address(0)) {
// decrease old representative
uint32 srcRepNum = numCheckpoints[srcRep];
uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;
uint256 srcRepNew = srcRepOld.sub(amount);
_writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);
}
if (dstRep != address(0)) {
// increase new representative
uint32 dstRepNum = numCheckpoints[dstRep];
uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;
uint256 dstRepNew = dstRepOld.add(amount);
_writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);
}
}
}
function _writeCheckpoint(
address delegatee,
uint32 nCheckpoints,
uint256 oldVotes,
uint256 newVotes
)
internal
{
uint32 blockNumber = safe32(block.number, "TAP::_writeCheckpoint: block number exceeds 32 bits");
if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) {
checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;
} else {
checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes);
numCheckpoints[delegatee] = nCheckpoints + 1;
}
emit DelegateVotesChanged(delegatee, oldVotes, newVotes);
}
function safe32(uint n, string memory errorMessage) internal pure returns (uint32) {
require(n < 2**32, errorMessage);
return uint32(n);
}
function getChainId() internal pure returns (uint) {
uint256 chainId;
assembly { chainId := chainid() }
return chainId;
}
} | 11,081 |
8 | // Returns the number of decimals of the locked token | function decimals() public view returns (uint8) {
return token.decimals();
}
| function decimals() public view returns (uint8) {
return token.decimals();
}
| 20,835 |
8 | // Returns smart contract to normal state / | function unpause()
public
onlyOwner
| function unpause()
public
onlyOwner
| 68,677 |
203 | // called by providers | function migrateProvider(address _newProvider) external onlyAllowed {
IJointProvider newProvider = IJointProvider(_newProvider);
if (newProvider.want() == tokenA) {
providerA = newProvider;
} else if (newProvider.want() == tokenB) {
providerB = newProvider;
} else {
revert("Unsupported token");
}
}
| function migrateProvider(address _newProvider) external onlyAllowed {
IJointProvider newProvider = IJointProvider(_newProvider);
if (newProvider.want() == tokenA) {
providerA = newProvider;
} else if (newProvider.want() == tokenB) {
providerB = newProvider;
} else {
revert("Unsupported token");
}
}
| 33,910 |
28 | // Remove `minters` from minters and reset mint cap to 0.If `minter` is minters, emits a `MinterRemoved` event._minters The minters to remove Requirements:- the caller must be `owner`, `_token` must be a MSD Token. / | function _removeMinters(address _token, address[] calldata _minters)
external
onlyOwner
onlyMSD(_token)
| function _removeMinters(address _token, address[] calldata _minters)
external
onlyOwner
onlyMSD(_token)
| 37,555 |
151 | // adjustments[1]/mload(0x57e0), Constraint expression for cpu/operands/mem1_addr: column19_row12 + half_offset_size - (cpu__decode__opcode_rc__bit_2column19_row0 + cpu__decode__opcode_rc__bit_4column21_row0 + cpu__decode__opcode_rc__bit_3column21_row8 + (1 - (cpu__decode__opcode_rc__bit_2 + cpu__decode__opcode_rc__bit_4 + cpu__decode__opcode_rc__bit_3))column19_row5 + column0_row4). | let val := addmod(
addmod(/*column19_row12*/ mload(0x3e80), /*half_offset_size*/ mload(0xc0), PRIME),
sub(
PRIME,
addmod(
addmod(
addmod(
addmod(
mulmod(
| let val := addmod(
addmod(/*column19_row12*/ mload(0x3e80), /*half_offset_size*/ mload(0xc0), PRIME),
sub(
PRIME,
addmod(
addmod(
addmod(
addmod(
mulmod(
| 24,691 |
14 | // go through the list of all insurances related to the given flight | for (uint i = 0; i < insuranceList[flightId].length; i++) {
| for (uint i = 0; i < insuranceList[flightId].length; i++) {
| 47,339 |
212 | // It allows owner to set the cToken address_cToken : new cToken address / | function setCToken(address _cToken)
| function setCToken(address _cToken)
| 22,486 |
25 | // Private Functions // Deterministically generates a seed from the block hash at the block number of creation of the validationdata plus MAXIMUM_NUM_SIGNERS Note that `blockhash(blockNum)` will only work for the 256 most recent blocks. If`completeSignatureCommitment` is called too late, a new call to `newSignatureCommitment` is necessary to resetvalidation data's block number data a storage reference to the validationData structreturn onChainRandNums an array storing the random numbers generated inside this function / | function getSeed(ValidationData storage data)
private
view
returns (uint256)
| function getSeed(ValidationData storage data)
private
view
returns (uint256)
| 36,832 |
126 | // The timestamp at which voting ends: votes must be cast prior to this timestamp | uint endTime;
| uint endTime;
| 7,521 |
44 | // our contract calls 'receiveApproval' function of another contract ('allowanceRecipient') to send information about allowance and data sent by user 'this' is this (our) contract address | if (spender.receiveApproval(msg.sender, _value, this, _extraData)) {
DataSentToAnotherContract(msg.sender, _spender, _extraData);
return true;
}
| if (spender.receiveApproval(msg.sender, _value, this, _extraData)) {
DataSentToAnotherContract(msg.sender, _spender, _extraData);
return true;
}
| 7,552 |
296 | // Finalize starting index / | function finalizeStartingIndex() public {
require(startingIndex == 0, "Starting index is already set");
require(startingIndexBlock != 0, "Starting index block must be set");
startingIndex = uint256(blockhash(startingIndexBlock)) % MAX_NFT_SUPPLY;
// Just a sanity case in the worst case if this function is called late (EVM only stores last 256 block hashes)
if (block.number.sub(startingIndexBlock) > 255) {
startingIndex =
uint256(blockhash(block.number - 1)) %
MAX_NFT_SUPPLY;
}
// Prevent default sequence
if (startingIndex == 0) {
startingIndex = startingIndex.add(1);
}
}
| function finalizeStartingIndex() public {
require(startingIndex == 0, "Starting index is already set");
require(startingIndexBlock != 0, "Starting index block must be set");
startingIndex = uint256(blockhash(startingIndexBlock)) % MAX_NFT_SUPPLY;
// Just a sanity case in the worst case if this function is called late (EVM only stores last 256 block hashes)
if (block.number.sub(startingIndexBlock) > 255) {
startingIndex =
uint256(blockhash(block.number - 1)) %
MAX_NFT_SUPPLY;
}
// Prevent default sequence
if (startingIndex == 0) {
startingIndex = startingIndex.add(1);
}
}
| 17,988 |
3 | // Maps challengeID to challenge struct | mapping(uint => Challenge) public challenges;
| mapping(uint => Challenge) public challenges;
| 24,589 |
66 | // transfer is basic transfer with isFreeze modifer | function transfer(address recipient, uint256 amount) public virtual override isFreeze(_msgSender(), amount) returns (bool) {
return super.transfer(recipient, amount);
}
| function transfer(address recipient, uint256 amount) public virtual override isFreeze(_msgSender(), amount) returns (bool) {
return super.transfer(recipient, amount);
}
| 12,044 |
11 | // Paybacks debt to the CDP | ICropper(CROPPER).frob(
_ilk,
owner,
owner,
owner,
0,
normalizePaybackAmount(address(vat), daiVatBalance, _urn, _ilk)
);
| ICropper(CROPPER).frob(
_ilk,
owner,
owner,
owner,
0,
normalizePaybackAmount(address(vat), daiVatBalance, _urn, _ilk)
);
| 5,415 |
6 | // Return Auction Price | if (now <= startDate) {
return startPrice;
}
| if (now <= startDate) {
return startPrice;
}
| 43,820 |
9 | // Increases the user's balance to reflect their newly purchased tokens | tokenbalance[msg.sender] = tokenbalance[msg.sender].add(amount);
| tokenbalance[msg.sender] = tokenbalance[msg.sender].add(amount);
| 5,591 |
34 | // Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`call, or as part of the Solidity `fallback` or `receive` functions. If overriden should call `super._beforeFallback()`. / | function _beforeFallback() internal virtual {}
}
| function _beforeFallback() internal virtual {}
}
| 9,529 |
13 | // Whether or not this market is listed | bool isListed;
| bool isListed;
| 9,023 |
2 | // Emitted when token is deactivated _address Address of the token / | event TokenDeactivate(address indexed _address);
| event TokenDeactivate(address indexed _address);
| 26,494 |
21 | // VF does not exist. / | None,
| None,
| 22,435 |
25 | // new user so add to number of users | numUsers++;
allUsersById.push(msg.sender);
zeroMatches = true;
| numUsers++;
allUsersById.push(msg.sender);
zeroMatches = true;
| 16,867 |
77 | // _approve(msg.sender, spender, value); | allowance[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
| allowance[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
| 7,427 |
21 | // if trade failed unexpectedly (`makerExecute` reverted or Mangrove failed to transfer the outbound tokens to the Offer Taker) | __posthookFallback__(order, result);
return;
| __posthookFallback__(order, result);
return;
| 51,742 |
62 | // allows oracles to check that sufficient LINK balance is availablereturn availableBalance LINK available on this contract, after accounting for outstanding obligations. can become negative / | function linkAvailableForPayment()
external
view
returns (int256 availableBalance)
| function linkAvailableForPayment()
external
view
returns (int256 availableBalance)
| 22,838 |
0 | // token address + amount | mapping(address => uint256) claimable;
| mapping(address => uint256) claimable;
| 18,707 |
121 | // Adds two numbers, reverts on overflow. / | function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a);
return c;
}
| function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a);
return c;
}
| 6,358 |
3 | // Token in which prices are quoted. It's most likely WETH, however it could vary from deployment/ to deployment. For example 1 SILO costs X amount of quoteToken. | address public immutable override quoteToken;
| address public immutable override quoteToken;
| 38,365 |
1 | // Minimum percentage difference between the last bid and the current bid | uint16 constant public minimumIncrementPercentage = 500; // 5%
| uint16 constant public minimumIncrementPercentage = 500; // 5%
| 66,840 |
6 | // Adds two numbers, throws on overflow. / | function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
| function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
| 23,857 |
26 | // Increment the host counter to account for the new host. | num_hosts += 1;
| num_hosts += 1;
| 11,926 |
10 | // check the remaining amount to be staked | uint256 remaining = amount;
if (remaining > (stakingCap.sub(stakedBalance))) {
remaining = stakingCap.sub(stakedBalance);
}
| uint256 remaining = amount;
if (remaining > (stakingCap.sub(stakedBalance))) {
remaining = stakingCap.sub(stakedBalance);
}
| 47,298 |
63 | // The last Unix timestamp (in seconds) when rewardPerTokenStored was updated | uint64 public lastUpdateTime;
| uint64 public lastUpdateTime;
| 19,461 |
144 | // accrues interest and updates the interest rate model using _setInterestRateModelFresh Admin function to accrue interest and update the interest rate model newInterestRateModel the new interest rate model to usereturn uint 0=success, otherwise a failure (see ErrorReporter.sol for details) / | function _setInterestRateModel(address newInterestRateModel) public override returns (uint256) {
uint256 error = accrueInterest();
if (error != uint256(Error.NO_ERROR)) {
// accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted change of interest rate model failed
Error(error).fail(FailureInfo.SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED);
}
// _setInterestRateModelFresh emits interest-rate-model-update-specific logs on errors, so we don't need to.
return _setInterestRateModelFresh(newInterestRateModel);
}
| function _setInterestRateModel(address newInterestRateModel) public override returns (uint256) {
uint256 error = accrueInterest();
if (error != uint256(Error.NO_ERROR)) {
// accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted change of interest rate model failed
Error(error).fail(FailureInfo.SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED);
}
// _setInterestRateModelFresh emits interest-rate-model-update-specific logs on errors, so we don't need to.
return _setInterestRateModelFresh(newInterestRateModel);
}
| 2,092 |
22 | // Ensure a valid form of collateral is tied to this agreement id | require(collateralAmount > 0);
require(collateralToken != address(0));
| require(collateralAmount > 0);
require(collateralToken != address(0));
| 2,137 |
14 | // round 12 | t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 8969172011633935669771678412400911310465619639756845342775631896478908389850)
t0 := sbox_partial(t0, q)
t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
| t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 8969172011633935669771678412400911310465619639756845342775631896478908389850)
t0 := sbox_partial(t0, q)
t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
| 24,328 |
33 | // Receive the response in the form of string, access it with the 'getSpiderwebPrediction' function / | function linkFulfillPredictionRequest(bytes32 _requestId, string memory _inference) public
| function linkFulfillPredictionRequest(bytes32 _requestId, string memory _inference) public
| 11,748 |
223 | // Hash the parameters ,and return the hash value_token -the token to pay for register or promotion an address._fee- fee needed for register an address._beneficiary- the beneficiary payment address return bytes32 -the parameters hash/ | function getParametersHash(IERC20 _token, uint256 _fee, address _beneficiary)
public pure returns(bytes32)
| function getParametersHash(IERC20 _token, uint256 _fee, address _beneficiary)
public pure returns(bytes32)
| 37,385 |
29 | // Function to access decimals of token . | function decimals() public constant returns (uint8) {
return decimals;
}
| function decimals() public constant returns (uint8) {
return decimals;
}
| 35,794 |
64 | // helper for sendOrMint action to update the rewarder daily limit if updateFrequency passed / | function _updateDailyLimitCap(Supply storage minter) internal {
uint256 secondsPassed = block.timestamp - minter.lastUpdate;
if (secondsPassed >= updateFrequency) {
minter.dailyCap = uint128(
(IERC20Upgradeable(token).totalSupply() * minter.bpsPerDay) / 10000
);
minter.lastUpdate = uint128(block.timestamp);
// console.log(
// "secondsPassed %s %s %s",
// secondsPassed,
// minter.dailyCap,
// minter.lastUpdate
// );
}
}
| function _updateDailyLimitCap(Supply storage minter) internal {
uint256 secondsPassed = block.timestamp - minter.lastUpdate;
if (secondsPassed >= updateFrequency) {
minter.dailyCap = uint128(
(IERC20Upgradeable(token).totalSupply() * minter.bpsPerDay) / 10000
);
minter.lastUpdate = uint128(block.timestamp);
// console.log(
// "secondsPassed %s %s %s",
// secondsPassed,
// minter.dailyCap,
// minter.lastUpdate
// );
}
}
| 25,082 |
7 | // Events |
event Claim(uint256 tokenId, address indexed to);
event Transfer(uint256 tokenId, address indexed from, address indexed to);
event ForSaleDeclared(uint256 indexed tokenId, address indexed from,
uint256 minValue,address indexed to);
event ForSaleWithdrawn(uint256 indexed tokenId, address indexed from);
event ForSaleBought(uint256 indexed tokenId, uint256 value,
address indexed from, address indexed to);
event BidDeclared(uint256 indexed tokenId, uint256 value,
|
event Claim(uint256 tokenId, address indexed to);
event Transfer(uint256 tokenId, address indexed from, address indexed to);
event ForSaleDeclared(uint256 indexed tokenId, address indexed from,
uint256 minValue,address indexed to);
event ForSaleWithdrawn(uint256 indexed tokenId, address indexed from);
event ForSaleBought(uint256 indexed tokenId, uint256 value,
address indexed from, address indexed to);
event BidDeclared(uint256 indexed tokenId, uint256 value,
| 22,610 |
4 | // Identity Registry contract used by the onchain validator system | IIdentityRegistry internal _tokenIdentityRegistry;
| IIdentityRegistry internal _tokenIdentityRegistry;
| 5,495 |
102 | // ensure this pair is a univ2 pair by querying the factory | IUniswapV2Pair lpair = IUniswapV2Pair(address(_lpToken));
address factoryPairAddress = uniswapFactory.getPair(lpair.token0(), lpair.token1());
require(factoryPairAddress == address(_lpToken), 'NOT UNIV2');
TransferHelper.safeTransferFrom(_lpToken, address(msg.sender), address(this), _amount);
if (_referral != address(0) && address(gFees.referralToken) != address(0)) {
require(gFees.referralToken.balanceOf(_referral) >= gFees.referralHold, 'INADEQUATE BALANCE');
}
| IUniswapV2Pair lpair = IUniswapV2Pair(address(_lpToken));
address factoryPairAddress = uniswapFactory.getPair(lpair.token0(), lpair.token1());
require(factoryPairAddress == address(_lpToken), 'NOT UNIV2');
TransferHelper.safeTransferFrom(_lpToken, address(msg.sender), address(this), _amount);
if (_referral != address(0) && address(gFees.referralToken) != address(0)) {
require(gFees.referralToken.balanceOf(_referral) >= gFees.referralHold, 'INADEQUATE BALANCE');
}
| 25,381 |
154 | // Extend parent behavior requiring purchase to respect the funding cap. beneficiary Token purchaser weiAmount Amount of wei contributed / | function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal view {
super._preValidatePurchase(beneficiary, weiAmount);
require(weiRaised().add(weiAmount) <= _cap, "CappedCrowdsale: cap exceeded");
}
| function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal view {
super._preValidatePurchase(beneficiary, weiAmount);
require(weiRaised().add(weiAmount) <= _cap, "CappedCrowdsale: cap exceeded");
}
| 6,499 |
189 | // Calculate the dy, the amount of selected token that user receives andthe fee of withdrawing in one token account the address that is withdrawing tokenAmount the amount to withdraw in the pool's precision tokenIndex which token will be withdrawn self Swap struct to read fromreturn the amount of token user will receive and the associated swap fee / | function calculateWithdrawOneToken(
Swap storage self,
address account,
uint256 tokenAmount,
uint8 tokenIndex
| function calculateWithdrawOneToken(
Swap storage self,
address account,
uint256 tokenAmount,
uint8 tokenIndex
| 17,356 |
21 | // address of the creator | address private visionDog;
| address private visionDog;
| 5,047 |
97 | // Withdraw (unowed) contract balance. | function withdrawFreeBalance() external {
// Calculate the free (unowed) balance. This never underflows, as
// outstandingEther is guaranteed to be less than or equal to the
// contract balance.
uint256 freeBalance = this.balance - outstandingEther;
address deedContractAddress = address(deedContract);
require(
msg.sender == owner ||
msg.sender == deedContractAddress
);
deedContractAddress.transfer(freeBalance);
}
| function withdrawFreeBalance() external {
// Calculate the free (unowed) balance. This never underflows, as
// outstandingEther is guaranteed to be less than or equal to the
// contract balance.
uint256 freeBalance = this.balance - outstandingEther;
address deedContractAddress = address(deedContract);
require(
msg.sender == owner ||
msg.sender == deedContractAddress
);
deedContractAddress.transfer(freeBalance);
}
| 12,524 |
55 | // loop through each price | for (uint8 i = 1; i < twaps.length; i++) {
| for (uint8 i = 1; i < twaps.length; i++) {
| 34,598 |
11 | // Create a function to return the total coffee | function getTotalCoffee() public view returns (uint256) {
return totalCoffee;
}
| function getTotalCoffee() public view returns (uint256) {
return totalCoffee;
}
| 11,673 |
75 | // refund the last bidder | if( bidsLength > 0 ) {
if(!lastBid.from.send(lastBid.amount)) {
revert();
}
| if( bidsLength > 0 ) {
if(!lastBid.from.send(lastBid.amount)) {
revert();
}
| 44,362 |
8 | // Send a transaction to L1 destination recipient address on L1 calldataForL1 (optional) calldata for L1 contract callreturn a unique identifier for this L2-to-L1 transaction. / | function sendTxToL1(address destination, bytes calldata calldataForL1)
external
payable
returns (uint256);
| function sendTxToL1(address destination, bytes calldata calldataForL1)
external
payable
returns (uint256);
| 7,501 |
3 | // Query and return price for a given PUT or CALL option | function getBuyPrice(
OptionsModel.Option memory option,
uint256 amountToBuy,
address paymentTokenAddress
) external view returns (uint256);
| function getBuyPrice(
OptionsModel.Option memory option,
uint256 amountToBuy,
address paymentTokenAddress
) external view returns (uint256);
| 38,919 |
260 | // requires that gauge has approval for lp token | function _stakeAllLp() internal virtual {
uint256 balance = IERC20(crvLp).balanceOf(address(this));
if (balance != 0) {
ILiquidityGaugeV2(crvGauge).deposit(balance);
}
}
| function _stakeAllLp() internal virtual {
uint256 balance = IERC20(crvLp).balanceOf(address(this));
if (balance != 0) {
ILiquidityGaugeV2(crvGauge).deposit(balance);
}
}
| 63,573 |
54 | // Administrable The Admin contract defines a single Admin who can transfer the ownership of a contract to a new address, even if he is not the owner. A Admin can transfer his role to a new address./ | contract Administrable is Ownable, RBAC {
string public constant ROLE_LOCKUP = "lockup";
string public constant ROLE_MINT = "mint";
constructor () public {
addRole(msg.sender, ROLE_LOCKUP);
addRole(msg.sender, ROLE_MINT);
}
/**
* @dev Throws if called by any account that's not a Admin.
*/
modifier onlyAdmin(string _role) {
checkRole(msg.sender, _role);
_;
}
modifier onlyOwnerOrAdmin(string _role) {
require(msg.sender == owner || isAdmin(msg.sender, _role));
_;
}
/**
* @dev getter to determine if address has Admin role
*/
function isAdmin(address _addr, string _role)
public
view
returns (bool)
{
return hasRole(_addr, _role);
}
/**
* @dev add a admin role to an address
* @param _operator address
* @param _role the name of the role
*/
function addAdmin(address _operator, string _role)
public
onlyOwner
{
addRole(_operator, _role);
}
/**
* @dev remove a admin role from an address
* @param _operator address
* @param _role the name of the role
*/
function removeAdmin(address _operator, string _role)
public
onlyOwner
{
removeRole(_operator, _role);
}
/**
* @dev claim a admin role from an address
* @param _role the name of the role
*/
function claimAdmin(string _role)
public
onlyOwner
{
removeRoleAll(_role);
addRole(msg.sender, _role);
}
}
| contract Administrable is Ownable, RBAC {
string public constant ROLE_LOCKUP = "lockup";
string public constant ROLE_MINT = "mint";
constructor () public {
addRole(msg.sender, ROLE_LOCKUP);
addRole(msg.sender, ROLE_MINT);
}
/**
* @dev Throws if called by any account that's not a Admin.
*/
modifier onlyAdmin(string _role) {
checkRole(msg.sender, _role);
_;
}
modifier onlyOwnerOrAdmin(string _role) {
require(msg.sender == owner || isAdmin(msg.sender, _role));
_;
}
/**
* @dev getter to determine if address has Admin role
*/
function isAdmin(address _addr, string _role)
public
view
returns (bool)
{
return hasRole(_addr, _role);
}
/**
* @dev add a admin role to an address
* @param _operator address
* @param _role the name of the role
*/
function addAdmin(address _operator, string _role)
public
onlyOwner
{
addRole(_operator, _role);
}
/**
* @dev remove a admin role from an address
* @param _operator address
* @param _role the name of the role
*/
function removeAdmin(address _operator, string _role)
public
onlyOwner
{
removeRole(_operator, _role);
}
/**
* @dev claim a admin role from an address
* @param _role the name of the role
*/
function claimAdmin(string _role)
public
onlyOwner
{
removeRoleAll(_role);
addRole(msg.sender, _role);
}
}
| 20,573 |
35 | // The only error `div` can return is MathError.DIVISION_BY_ZERO but we control `expScale` and it is not zero. | assert(err2 == MathError.NO_ERROR);
| assert(err2 == MathError.NO_ERROR);
| 3,279 |
20 | // Allows the payee to initiate an emergency claim after a six months lockperiod . _paymentRef Reference of the related Invoice. Uses modifiers OnlyPayee, IsInEscrow, IsNotInEmergencyState and IsNotFrozen. / | function initiateEmergencyClaim(bytes memory _paymentRef)
external
OnlyPayee(_paymentRef)
IsInEscrow(_paymentRef)
IsNotInEmergencyState(_paymentRef)
IsNotFrozen(_paymentRef)
| function initiateEmergencyClaim(bytes memory _paymentRef)
external
OnlyPayee(_paymentRef)
IsInEscrow(_paymentRef)
IsNotInEmergencyState(_paymentRef)
IsNotFrozen(_paymentRef)
| 22,691 |
4 | // costs a set percentage of tokens deposited | require(amount > 1000, "Deposit too low");
require(length > 0 && length < 10000, "9999 days max lock");
address _owner = owner();
uint leftoverAmount;
uint fee;
IERC20 lp = IERC20(token);
lp.transferFrom(msg.sender, address(this), amount);
fee = amount / lpFee;
leftoverAmount = amount - fee;
require((leftoverAmount + fee) <= amount, "Error in rounding");
| require(amount > 1000, "Deposit too low");
require(length > 0 && length < 10000, "9999 days max lock");
address _owner = owner();
uint leftoverAmount;
uint fee;
IERC20 lp = IERC20(token);
lp.transferFrom(msg.sender, address(this), amount);
fee = amount / lpFee;
leftoverAmount = amount - fee;
require((leftoverAmount + fee) <= amount, "Error in rounding");
| 20,922 |
10 | // Contract address of chainlink aggregator | address chainlink;
| address chainlink;
| 48,086 |
149 | // liquidate tokens for ETH when the contract reaches 0.7 tokens by default | uint256 public liquidateTokensAtAmount = 8888 * (10**14);
| uint256 public liquidateTokensAtAmount = 8888 * (10**14);
| 23,528 |
1 | // Return value return value of 'number' / | function retrieve() public view returns (uint256){
return number;
}
| function retrieve() public view returns (uint256){
return number;
}
| 23,883 |
8 | // sets the eth amount at which it will use standard weighting vs buying a single derivative _amount - amount of eth where it will switch to standard weighting / | function setSingleDerivativeThreshold(uint256 _amount) external onlyOwner {
singleDerivativeThreshold = _amount;
emit SingleDerivativeThresholdUpdated(_amount);
}
| function setSingleDerivativeThreshold(uint256 _amount) external onlyOwner {
singleDerivativeThreshold = _amount;
emit SingleDerivativeThresholdUpdated(_amount);
}
| 10,197 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.