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 |
|---|---|---|---|---|
449 | // where q_{}(X) are selectors a, b, c, d - state (witness) polynomials q_d_next(X) "peeks" into the next row of the trace, so it takes the same d(X) polynomial, but shifted |
function aggregate_for_verification(Proof memory proof, VerificationKey memory vk)
internal
view
returns (bool valid, PairingsBn254.G1Point[2] memory part)
{
PartialVerifierState memory state;
valid = verify_initial(state, proof, vk);
|
function aggregate_for_verification(Proof memory proof, VerificationKey memory vk)
internal
view
returns (bool valid, PairingsBn254.G1Point[2] memory part)
{
PartialVerifierState memory state;
valid = verify_initial(state, proof, vk);
| 16,208 |
33 | // Checks if address given have signed the transaction transactionId Id of multi signature transactionsigner Address to be checked return have signed / | function checkSign(uint transactionId, address signer)
view
internal
returns(bool)
| function checkSign(uint transactionId, address signer)
view
internal
returns(bool)
| 49,969 |
121 | // Determines whether a move is a legal move or not (includes checking whether king is/ checked or not after the move)./_board The board to analyze./_move The move to check./ return Whether the move is legal or not. | function isLegalMove(uint256 _board, uint256 _move) internal pure returns (bool) {
unchecked {
uint256 fromIndex = _move >> 6;
uint256 toIndex = _move & 0x3F;
if ((0x7E7E7E7E7E7E00 >> fromIndex) & 1 == 0) return false;
if ((0x7E7E7E7E7E7E00 >> toIndex) & 1 == 0) return false;
uint256 pieceAtFromIndex = (_board >> (fromIndex << 2)) & 0xF;
if (pieceAtFromIndex == 0) return false;
if (pieceAtFromIndex >> 3 != _board & 1) return false;
pieceAtFromIndex &= 7;
uint256 adjustedBoard = _board >> (toIndex << 2);
uint256 indexChange = toIndex < fromIndex
? fromIndex - toIndex
: toIndex - fromIndex;
if (pieceAtFromIndex == 1) {
if (toIndex <= fromIndex) return false;
indexChange = toIndex - fromIndex;
if ((indexChange == 7 || indexChange == 9)) {
if (!_board.isCapture(adjustedBoard)) return false;
} else if (indexChange == 8) {
if (!isValid(_board, toIndex)) return false;
} else if (indexChange == 0x10) {
if (!isValid(_board, toIndex - 8) || !isValid(_board, toIndex)) return false;
} else {
return false;
}
} else if (pieceAtFromIndex == 4 || pieceAtFromIndex == 6) {
if (((pieceAtFromIndex == 4 ? 0x28440 : 0x382) >> indexChange) & 1 == 0) {
return false;
}
if (!isValid(_board, toIndex)) return false;
} else {
bool rayFound;
if (pieceAtFromIndex != 2) {
rayFound = searchRay(_board, fromIndex, toIndex, 1)
|| searchRay(_board, fromIndex, toIndex, 8);
}
if (pieceAtFromIndex != 3) {
rayFound = rayFound
|| searchRay(_board, fromIndex, toIndex, 7)
|| searchRay(_board, fromIndex, toIndex, 9);
}
if (!rayFound) return false;
}
if (Engine.negaMax(_board.applyMove(_move), 1) < -1_260) return false;
return true;
}
}
| function isLegalMove(uint256 _board, uint256 _move) internal pure returns (bool) {
unchecked {
uint256 fromIndex = _move >> 6;
uint256 toIndex = _move & 0x3F;
if ((0x7E7E7E7E7E7E00 >> fromIndex) & 1 == 0) return false;
if ((0x7E7E7E7E7E7E00 >> toIndex) & 1 == 0) return false;
uint256 pieceAtFromIndex = (_board >> (fromIndex << 2)) & 0xF;
if (pieceAtFromIndex == 0) return false;
if (pieceAtFromIndex >> 3 != _board & 1) return false;
pieceAtFromIndex &= 7;
uint256 adjustedBoard = _board >> (toIndex << 2);
uint256 indexChange = toIndex < fromIndex
? fromIndex - toIndex
: toIndex - fromIndex;
if (pieceAtFromIndex == 1) {
if (toIndex <= fromIndex) return false;
indexChange = toIndex - fromIndex;
if ((indexChange == 7 || indexChange == 9)) {
if (!_board.isCapture(adjustedBoard)) return false;
} else if (indexChange == 8) {
if (!isValid(_board, toIndex)) return false;
} else if (indexChange == 0x10) {
if (!isValid(_board, toIndex - 8) || !isValid(_board, toIndex)) return false;
} else {
return false;
}
} else if (pieceAtFromIndex == 4 || pieceAtFromIndex == 6) {
if (((pieceAtFromIndex == 4 ? 0x28440 : 0x382) >> indexChange) & 1 == 0) {
return false;
}
if (!isValid(_board, toIndex)) return false;
} else {
bool rayFound;
if (pieceAtFromIndex != 2) {
rayFound = searchRay(_board, fromIndex, toIndex, 1)
|| searchRay(_board, fromIndex, toIndex, 8);
}
if (pieceAtFromIndex != 3) {
rayFound = rayFound
|| searchRay(_board, fromIndex, toIndex, 7)
|| searchRay(_board, fromIndex, toIndex, 9);
}
if (!rayFound) return false;
}
if (Engine.negaMax(_board.applyMove(_move), 1) < -1_260) return false;
return true;
}
}
| 63,341 |
81 | // Compute square root of xx num to sqrt return sqrt(x)/ | function sqrt(uint x) internal pure returns (uint){
uint n = x / 2;
uint lstX = 0;
while (n != lstX){
lstX = n;
n = (n + x/n) / 2;
}
return uint(n);
}
| function sqrt(uint x) internal pure returns (uint){
uint n = x / 2;
uint lstX = 0;
while (n != lstX){
lstX = n;
n = (n + x/n) / 2;
}
return uint(n);
}
| 56,365 |
15 | // if you don&39;t have enough balance, throw | if(_balances[from] < value) revert();
| if(_balances[from] < value) revert();
| 57,542 |
27 | // Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),Reverts with custom message when dividing by zero. Counterpart to Solidity's `%` operator. This function uses a `revert`opcode (which leaves remaining gas untouched) while Solidity uses aninvalid opcode to revert (consuming all remaining gas). Requirements:- The divisor cannot be zero. _Available since v2.4.0._ / | function mod(uint256 a, uint256 b, string memory errorMessage)
internal
pure
returns (uint256)
| function mod(uint256 a, uint256 b, string memory errorMessage)
internal
pure
returns (uint256)
| 13,718 |
12 | // check result should not be other wise until a=0 | assert(a == 0 || c / a == b);
return c;
| assert(a == 0 || c / a == b);
return c;
| 29,757 |
1 | // ========== MIGRATION ========== / | enum TYPE {
UNSTAKED,
STAKED,
WRAPPED
}
| enum TYPE {
UNSTAKED,
STAKED,
WRAPPED
}
| 20,565 |
55 | // Emit a PayDealCreationFees | emit PayDealCreationFees(msg.sender, dealId, creationFeesInWEI);
return dealId;
| emit PayDealCreationFees(msg.sender, dealId, creationFeesInWEI);
return dealId;
| 29,305 |
8 | // Pauses all token transfers. | * See {ERC20Pausable} and {Pausable-_pause}.
*
* Requirements:
*
* - the caller must have the `PAUSER_ROLE`.
*/
function pause() public onlyRole(PAUSER_ROLE) {
_pause();
}
| * See {ERC20Pausable} and {Pausable-_pause}.
*
* Requirements:
*
* - the caller must have the `PAUSER_ROLE`.
*/
function pause() public onlyRole(PAUSER_ROLE) {
_pause();
}
| 3,527 |
732 | // Re-insert the node at a new position, based on its new NICR _id Node's id _newNICR Node's new NICR _prevId Id of previous node for the new insert position _nextId Id of next node for the new insert position / | function reInsert(address _id, uint256 _newNICR, address _prevId, address _nextId) external override {
ITroveManager troveManagerCached = troveManager;
_requireCallerIsBOorTroveM(troveManagerCached);
// List must contain the node
require(contains(_id), "SortedTroves: List does not contain the id");
// NICR must be non-zero
require(_newNICR > 0, "SortedTroves: NICR must be positive");
// Remove node from the list
_remove(_id);
_insert(troveManagerCached, _id, _newNICR, _prevId, _nextId);
}
| function reInsert(address _id, uint256 _newNICR, address _prevId, address _nextId) external override {
ITroveManager troveManagerCached = troveManager;
_requireCallerIsBOorTroveM(troveManagerCached);
// List must contain the node
require(contains(_id), "SortedTroves: List does not contain the id");
// NICR must be non-zero
require(_newNICR > 0, "SortedTroves: NICR must be positive");
// Remove node from the list
_remove(_id);
_insert(troveManagerCached, _id, _newNICR, _prevId, _nextId);
}
| 75,399 |
755 | // column17_row8214/ mload(0x2f40), Numerator: point - trace_generator^(8192(trace_length / 8192 - 1)). val = numerators[10]. | val := mulmod(val, mload(0x4ec0), PRIME)
| val := mulmod(val, mload(0x4ec0), PRIME)
| 51,753 |
33 | // Transfer the tokens to the claimer | IERC1155 nftContract = IERC1155(nftAddress);
nftContract.safeTransferFrom(address(this), msg.sender, tokenIds[i], rewardAmount, "");
| IERC1155 nftContract = IERC1155(nftAddress);
nftContract.safeTransferFrom(address(this), msg.sender, tokenIds[i], rewardAmount, "");
| 20,415 |
6 | // 用户邀请配套统计 | struct UserInvite {
uint256 number; // 配套总人数
uint256 amount; // 配套金额总数
}
| struct UserInvite {
uint256 number; // 配套总人数
uint256 amount; // 配套金额总数
}
| 5,763 |
2 | // stake -> 1 stakeGego 12 withdraw -> 2 withdrawGego 22 | event evenStakeOrWithdraw(address user, uint256 heroId, uint256 gegoIdOrAmount, uint256 stakeOrWithdraw);
event evenSetHero(uint256 gegoId, bool tag);
event evenSetOutsideActivityGego(uint256 gegoId, bool tag);
event evenSetGegoRule(uint256 ruleId, address erc20, uint256 priceRate);
event evenSetTeamPowerRewardConfig(uint256 index, uint256 num);
event evenSetPowerFactorRate(uint256 powerFactorRate);
event NFTReceived(address operator, address from, uint256 tokenId, bytes data);
| event evenStakeOrWithdraw(address user, uint256 heroId, uint256 gegoIdOrAmount, uint256 stakeOrWithdraw);
event evenSetHero(uint256 gegoId, bool tag);
event evenSetOutsideActivityGego(uint256 gegoId, bool tag);
event evenSetGegoRule(uint256 ruleId, address erc20, uint256 priceRate);
event evenSetTeamPowerRewardConfig(uint256 index, uint256 num);
event evenSetPowerFactorRate(uint256 powerFactorRate);
event NFTReceived(address operator, address from, uint256 tokenId, bytes data);
| 40,420 |
11 | // Returns list of friends of the sender | function getMyFriendList() external view returns(friend[] memory) {
return userList[msg.sender].friendList;
}
| function getMyFriendList() external view returns(friend[] memory) {
return userList[msg.sender].friendList;
}
| 29,654 |
17 | // Delegate interface to resign the implementation / | function _resignImplementation() public override {
require(
msg.sender == admin, "only the admin may abandon the implementation"
);
// Transfer all cash out of the DSR - note that this relies on self-transfer
DaiJoinLike daiJoin = DaiJoinLike(daiJoinAddress);
PotLike pot = PotLike(potAddress);
VatLike vat = VatLike(vatAddress);
// Accumulate interest
pot.drip();
// Calculate the total amount in the pot, and move it out
uint256 pie = pot.pie(address(this));
pot.exit(pie);
// Checks the actual balance of DAI in the vat after the pot exit
uint256 bal = vat.dai(address(this));
// Remove our whole balance
daiJoin.exit(address(this), bal / RAY);
}
| function _resignImplementation() public override {
require(
msg.sender == admin, "only the admin may abandon the implementation"
);
// Transfer all cash out of the DSR - note that this relies on self-transfer
DaiJoinLike daiJoin = DaiJoinLike(daiJoinAddress);
PotLike pot = PotLike(potAddress);
VatLike vat = VatLike(vatAddress);
// Accumulate interest
pot.drip();
// Calculate the total amount in the pot, and move it out
uint256 pie = pot.pie(address(this));
pot.exit(pie);
// Checks the actual balance of DAI in the vat after the pot exit
uint256 bal = vat.dai(address(this));
// Remove our whole balance
daiJoin.exit(address(this), bal / RAY);
}
| 4,270 |
9 | // return le nombre d'unités de Tokens qu'un acheteur obtient par wei. / | function rate() public view returns (uint256) {
return _rate;
}
| function rate() public view returns (uint256) {
return _rate;
}
| 15,465 |
68 | // See {ERC20-_mint}. / | function _mint(address account, uint256 amount) internal virtual override {
require(ERC20.totalSupply() + amount <= cap(), "ERC20Capped: cap exceeded");
super._mint(account, amount);
}
| function _mint(address account, uint256 amount) internal virtual override {
require(ERC20.totalSupply() + amount <= cap(), "ERC20Capped: cap exceeded");
super._mint(account, amount);
}
| 18,288 |
456 | // Do not send a value with the call if the exchange has an insufficient balance The protocolFeeCollector contract will fallback to charging WETH | if (exchangeBalance >= protocolFee) {
valuePaid = protocolFee;
}
| if (exchangeBalance >= protocolFee) {
valuePaid = protocolFee;
}
| 14,443 |
30 | // address public stakePadTokenAddress = 0xd8b934580fcE35a11B58C6D73aDeE468a2833fa8; local | IERC20 stakepadToken = IERC20(stakePadTokenAddress);
address payable public devAddress;
address payable immutable DAOtreasuryAddress;
uint256 stakeCreationFeeInNativeCoin = 0.001 ether; //in native coin
uint256 stakeCreationFeeInToken = 100 ** 10 * 18; // fee in stakepad native tokens
uint256 public DAOstakeCreationfee = 2500; // 25% stake creation fee goes to DO treasure;
uint256 public totalStakes;
| IERC20 stakepadToken = IERC20(stakePadTokenAddress);
address payable public devAddress;
address payable immutable DAOtreasuryAddress;
uint256 stakeCreationFeeInNativeCoin = 0.001 ether; //in native coin
uint256 stakeCreationFeeInToken = 100 ** 10 * 18; // fee in stakepad native tokens
uint256 public DAOstakeCreationfee = 2500; // 25% stake creation fee goes to DO treasure;
uint256 public totalStakes;
| 1,326 |
245 | // 设置盲盒预售时间 / | function setOnPreSalesTime(uint256 _onPreSalesTime) external onlyOwner {
onPreSalesTime = _onPreSalesTime;
}
| function setOnPreSalesTime(uint256 _onPreSalesTime) external onlyOwner {
onPreSalesTime = _onPreSalesTime;
}
| 35,447 |
2 | // Coverage-Used Certicol Certification Authority (CA) ContractKen Sze <acken2@outlook.com>This contracts increases Provable callback gas limit by 10x. Do NOT use in production environment. / | contract CerticolCATestCoverage is CerticolCATestStandard {
/**
* @notice Override default provable_getPrice function in provableAPI_0.5.sol
*/
function provable_getPrice(string memory _datasource, uint) internal provableAPI returns (uint _queryPrice) {
return provable.getPrice(_datasource, 1052760);
}
/**
* @notice Override default provable_query function in provableAPI_0.5.sol
*/
function provable_query(string memory _datasource, string memory _arg, uint) internal provableAPI returns (bytes32 _id) {
uint price = provable.getPrice(_datasource, 1052760);
return provable.query_withGasLimit.value(price)(0, _datasource, _arg, 1052760);
}
} | contract CerticolCATestCoverage is CerticolCATestStandard {
/**
* @notice Override default provable_getPrice function in provableAPI_0.5.sol
*/
function provable_getPrice(string memory _datasource, uint) internal provableAPI returns (uint _queryPrice) {
return provable.getPrice(_datasource, 1052760);
}
/**
* @notice Override default provable_query function in provableAPI_0.5.sol
*/
function provable_query(string memory _datasource, string memory _arg, uint) internal provableAPI returns (bytes32 _id) {
uint price = provable.getPrice(_datasource, 1052760);
return provable.query_withGasLimit.value(price)(0, _datasource, _arg, 1052760);
}
} | 14,863 |
523 | // can't deposit galaxy to L2can't deposit contract-owned point to L2 | require( depositAddress != _target ||
( azimuth.getPointSize(_point) != Azimuth.Size.Galaxy &&
!azimuth.getOwner(_point).isContract() ) );
| require( depositAddress != _target ||
( azimuth.getPointSize(_point) != Azimuth.Size.Galaxy &&
!azimuth.getOwner(_point).isContract() ) );
| 39,305 |
2 | // The address interpreted as native token of the chain. | address public constant NATIVE_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
| address public constant NATIVE_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
| 29,001 |
7 | // Transfer tokens from msg.sender to this contract. msg.sender must have called approve() on the token contract._commitment MUST be based on a unique random preimage./ | function newTransferFromOtherBlockchain(address _otherBlockchainTokenContract, address _recipient, uint256 _amount, bytes32 _commitment) onlyAuthorisedRelayer() external {
// A transfer with the commitment can not already exist.
require(!destTransferExists(_commitment), "Transfer already exists");
// The token must be in the list of known tokens.
require(isDestAllowedToken(_otherBlockchainTokenContract), "Token not transferable");
uint256 timeLock = block.timestamp + destTimeLockPeriod;
destTransfers[_commitment] = DestTransfer(msg.sender, _recipient, _otherBlockchainTokenContract, _amount, _commitment, 0x0, timeLock, 0);
emit DestTransferInit(_commitment, msg.sender, _recipient, _otherBlockchainTokenContract, _amount, timeLock);
}
| function newTransferFromOtherBlockchain(address _otherBlockchainTokenContract, address _recipient, uint256 _amount, bytes32 _commitment) onlyAuthorisedRelayer() external {
// A transfer with the commitment can not already exist.
require(!destTransferExists(_commitment), "Transfer already exists");
// The token must be in the list of known tokens.
require(isDestAllowedToken(_otherBlockchainTokenContract), "Token not transferable");
uint256 timeLock = block.timestamp + destTimeLockPeriod;
destTransfers[_commitment] = DestTransfer(msg.sender, _recipient, _otherBlockchainTokenContract, _amount, _commitment, 0x0, timeLock, 0);
emit DestTransferInit(_commitment, msg.sender, _recipient, _otherBlockchainTokenContract, _amount, timeLock);
}
| 5,694 |
68 | // bank transfer can only be called by bank contract or exchange contract, bank transfer don't need the approval of the sender. | function bankTransfer(address _from, address _to, uint256 _amount) public override returns (bool){
require(contract_is_active == true );
require(msg.sender == bank_contract || msg.sender == exchange_contract);
require(_from != address(0), "ERC20: transfer from the zero address");
require(_to != address(0), "ERC20: transfer to the zero address");
require(_checkLockedBalance(_from, _amount)==true,"ERC20: can't transfer locked balance");
_transfer(_from, _to, _amount);
return(true);
}
| function bankTransfer(address _from, address _to, uint256 _amount) public override returns (bool){
require(contract_is_active == true );
require(msg.sender == bank_contract || msg.sender == exchange_contract);
require(_from != address(0), "ERC20: transfer from the zero address");
require(_to != address(0), "ERC20: transfer to the zero address");
require(_checkLockedBalance(_from, _amount)==true,"ERC20: can't transfer locked balance");
_transfer(_from, _to, _amount);
return(true);
}
| 4,555 |
10 | // maker currency amount | uint256 makerCurrencyNeed = amount.mul(order.price).div(PRICE_DIV);
uint256 makerCurrencyAmount = getCanSpendAmount(taker,currency,makerCurrencyNeed);
| uint256 makerCurrencyNeed = amount.mul(order.price).div(PRICE_DIV);
uint256 makerCurrencyAmount = getCanSpendAmount(taker,currency,makerCurrencyNeed);
| 1,961 |
217 | // return addrToENS(addr); |
ENSReverseLookup c = ENSReverseLookup(ENSReverseLookupContractAddr);
string[] memory addrENS = c.getNames([addr]);
return addrENS;
|
ENSReverseLookup c = ENSReverseLookup(ENSReverseLookupContractAddr);
string[] memory addrENS = c.getNames([addr]);
return addrENS;
| 12,848 |
26 | // ============ Constants ============ |
uint256 constant BASE = 10**18;
|
uint256 constant BASE = 10**18;
| 17,673 |
14 | // Push left side to stack | if (p > l + 1) {
top = top + 1;
stack[top] = l;
top = top + 1;
stack[top] = p - 1;
}
| if (p > l + 1) {
top = top + 1;
stack[top] = l;
top = top + 1;
stack[top] = p - 1;
}
| 6,807 |
194 | // Extension of {ERC20} that allows token holders to destroy both their own/Destroys `amount` tokens from the caller. See {ERC20-_burn}./ | function burn(uint256 amount) public virtual {
_burn(_msgSender(), amount);
}
| function burn(uint256 amount) public virtual {
_burn(_msgSender(), amount);
}
| 644 |
47 | // External //Changes the back up arbitrator. _arbitrator The new back up arbitrator./ | function changeArbitrator(Arbitrator _arbitrator) external onlyOwner {
arbitrator = _arbitrator;
}
| function changeArbitrator(Arbitrator _arbitrator) external onlyOwner {
arbitrator = _arbitrator;
}
| 51,254 |
43 | // Copy the full OrderParameters head from calldata to memory. | cdPtr.copy(mPtr, OrderParameters_head_size);
| cdPtr.copy(mPtr, OrderParameters_head_size);
| 17,235 |
111 | // ------------------------------------------------------------------------ Owner can transfer out any ETH ------------------------------------------------------------------------ | function withdrawEther(uint amount) public {
require(msg.sender == withdrawAddress);
require(amount <= this.balance);
require(amount <= safeWithdrawAmount);
safeWithdrawAmount = safeWithdrawAmount.sub(amount);
withdrawAddress.transfer(amount);
}
| function withdrawEther(uint amount) public {
require(msg.sender == withdrawAddress);
require(amount <= this.balance);
require(amount <= safeWithdrawAmount);
safeWithdrawAmount = safeWithdrawAmount.sub(amount);
withdrawAddress.transfer(amount);
}
| 44,544 |
211 | // Burns the given bToken for the proportional amount of underlying tokens./_to The address to send the underlying tokens to./_credit The amount of bToken to burn./ return amount The amount of underlying tokens getting transferred out. | function burn(address _to, uint _credit) external nonReentrant returns (uint amount) {
accrue();
uint supply = totalSupply();
amount = (_credit * (totalLoanable + totalLoan)) / supply;
require(amount > 0, 'burn/no-amount-returned');
totalLoanable -= amount;
_burn(msg.sender, _credit);
IERC20(underlying).safeTransfer(_to, amount);
emit Burn(msg.sender, _to, amount, _credit);
}
| function burn(address _to, uint _credit) external nonReentrant returns (uint amount) {
accrue();
uint supply = totalSupply();
amount = (_credit * (totalLoanable + totalLoan)) / supply;
require(amount > 0, 'burn/no-amount-returned');
totalLoanable -= amount;
_burn(msg.sender, _credit);
IERC20(underlying).safeTransfer(_to, amount);
emit Burn(msg.sender, _to, amount, _credit);
}
| 28,693 |
43 | // distribute the rest | honeyPotAmount += (msg.value * 597) / 20000;
devFund += (msg.value * 597) / 20000;
| honeyPotAmount += (msg.value * 597) / 20000;
devFund += (msg.value * 597) / 20000;
| 16,256 |
3 | // Allow spending tokens from addresses with balance Note that this still allows listings and marketplaces with escrow to transfer tokens if transferred from an EOA. | if (from == msg.sender) {
_;
return;
}
| if (from == msg.sender) {
_;
return;
}
| 21,287 |
49 | // Make new bet in exchange of bet token.affiliate the affiliate the bet is made fromconditionId the match or game IDamount amount of tokens to betoutcomeId ID of predicted outcomedeadline the time before which bet should be mademinOdds minimum allowed bet odds / | function bet(
address core,
address affiliate,
uint256 conditionId,
uint128 amount,
uint64 outcomeId,
uint64 deadline,
uint64 minOdds
| function bet(
address core,
address affiliate,
uint256 conditionId,
uint128 amount,
uint64 outcomeId,
uint64 deadline,
uint64 minOdds
| 9,277 |
26 | // Airdrops some tokens to some accounts. source The address of the current token holder. dests List of account addresses. values List of token amounts. Note that these are in wholetokens. Fractions of tokens are not supported. / | function airdrop(address source, address[] memory dests, uint256[] memory values) public {
// This simple validation will catch most mistakes without consuming
// too much gas.
require(dests.length == values.length, "Address and values doesn't match");
for (uint256 i = 0; i < dests.length; i++) {
require(transferFrom(source, dests[i], values[i]));
}
}
| function airdrop(address source, address[] memory dests, uint256[] memory values) public {
// This simple validation will catch most mistakes without consuming
// too much gas.
require(dests.length == values.length, "Address and values doesn't match");
for (uint256 i = 0; i < dests.length; i++) {
require(transferFrom(source, dests[i], values[i]));
}
}
| 37,195 |
109 | // Sets the address associated with an ENS node.May only be called by the owner of that node in the ENS registry. node The node to update. addr The address to set. / | function setAddr(bytes32 node, address addr) public only_owner(node) {
records[node].addr = addr;
AddrChanged(node, addr);
}
| function setAddr(bytes32 node, address addr) public only_owner(node) {
records[node].addr = addr;
AddrChanged(node, addr);
}
| 15,730 |
9 | // Transfers a `value` amount of tokens of type `id` from `from` to `to`. WARNING: This function can potentially allow a reentrancy attack when transferring tokensto an untrusted contract, when invoking {onERC1155Received} on the receiver.Ensure to follow the checks-effects-interactions pattern and consider employingreentrancy guards when interacting with untrusted contracts. Emits a {TransferSingle} event. Requirements: - `to` cannot be the zero address.- If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.- `from` must have a balance of tokens of type `id` of at least `value` amount.- If `to` refers to a smart contract, it | function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes calldata data) external;
| function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes calldata data) external;
| 14,295 |
112 | // special case for equal weights | if (_fromConnectorWeight == _toConnectorWeight)
return _toConnectorBalance.mul(_amount) / _fromConnectorBalance.add(_amount);
uint256 result;
uint8 precision;
uint256 baseN = _fromConnectorBalance.add(_amount);
(result, precision) = power(baseN, _fromConnectorBalance, _fromConnectorWeight, _toConnectorWeight);
uint256 temp1 = _toConnectorBalance.mul(result);
uint256 temp2 = _toConnectorBalance << precision;
return (temp1 - temp2) / result;
| if (_fromConnectorWeight == _toConnectorWeight)
return _toConnectorBalance.mul(_amount) / _fromConnectorBalance.add(_amount);
uint256 result;
uint8 precision;
uint256 baseN = _fromConnectorBalance.add(_amount);
(result, precision) = power(baseN, _fromConnectorBalance, _fromConnectorWeight, _toConnectorWeight);
uint256 temp1 = _toConnectorBalance.mul(result);
uint256 temp2 = _toConnectorBalance << precision;
return (temp1 - temp2) / result;
| 20,693 |
40 | // {See ICreatorCore-getFeeRecipients}. / | function getFeeRecipients(uint256 tokenId) external view virtual override returns (address payable[] memory) {
| function getFeeRecipients(uint256 tokenId) external view virtual override returns (address payable[] memory) {
| 62,280 |
141 | // Returns the number of elements in the map. O(1). / | function length(UintToAddressMap storage map) internal view returns (uint256) {
return _length(map._inner);
}
| function length(UintToAddressMap storage map) internal view returns (uint256) {
return _length(map._inner);
}
| 2,413 |
38 | // Event for update USD/ETH conversion rate oldRate old rate newRate new rate / | event USDETHRateUpdate(uint256 oldRate, uint256 newRate);
| event USDETHRateUpdate(uint256 oldRate, uint256 newRate);
| 46,870 |
41 | // add or remove allowed callers (usually FlareX router(s)) for swapNoFee function | function processAllowedCallers(address caller, bool isAllowed) override external returns (bool) {
require(msg.sender == factory, 'FlareX: FORBIDDEN');
_allowedCallers[caller] = isAllowed;
return true;
}
| function processAllowedCallers(address caller, bool isAllowed) override external returns (bool) {
require(msg.sender == factory, 'FlareX: FORBIDDEN');
_allowedCallers[caller] = isAllowed;
return true;
}
| 16,782 |
98 | // Transfers control of the contract to a newOwner. newOwner The address to transfer ownership to. / | function _transferOwnership(address newOwner) internal {
require(newOwner != address(0));
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
| function _transferOwnership(address newOwner) internal {
require(newOwner != address(0));
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
| 29,176 |
148 | // Reserves vault contract | address public reservesContract;
| address public reservesContract;
| 18,504 |
70 | // Convert a high precision decimal to a standard decimal representation. / | function preciseDecimalToDecimal(uint i) internal pure returns (uint) {
uint quotientTimesTen = i / (UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR / 10);
if (quotientTimesTen % 10 >= 5) {
quotientTimesTen += 10;
}
return quotientTimesTen / 10;
}
| function preciseDecimalToDecimal(uint i) internal pure returns (uint) {
uint quotientTimesTen = i / (UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR / 10);
if (quotientTimesTen % 10 >= 5) {
quotientTimesTen += 10;
}
return quotientTimesTen / 10;
}
| 8,132 |
416 | // Get the names of all registered `IZap`return An array of `IZap` names / | function zapNames() external view returns (string[] memory);
| function zapNames() external view returns (string[] memory);
| 56,504 |
72 | // Whitelist List of whitelisted users who can contribute. / | contract Whitelist is Ownable {
mapping(address => bool) public whitelist;
mapping(address => bool) public authorized;
event UserAllowed(address user);
event UserDisallowed(address user);
modifier onlyAuthorized {
require(msg.sender == owner || authorized[msg.sender]);
_;
}
/**
* @dev Adds single address to admins.
* @param _admin Address to be added to the admins
*/
function authorize(address _admin) external onlyOwner {
authorized[_admin] = true;
}
/**
* @dev Removes single address from admins.
* @param _admin Address to be removed from the admins
*/
function reject(address _admin) external onlyOwner {
authorized[_admin] = false;
}
/**
* @dev Adds single address to whitelist.
* @param _beneficiary Address to be added to the whitelist
*/
function addToWhitelist(address _beneficiary) external onlyAuthorized {
whitelist[_beneficiary] = true;
UserAllowed(_beneficiary);
}
/**
* @dev Adds list of addresses to whitelist. Not overloaded due to limitations with truffle testing.
* @param _beneficiaries Addresses to be added to the whitelist
*/
function addManyToWhitelist(address[] _beneficiaries) external onlyAuthorized {
for (uint i = 0; i < _beneficiaries.length; i++) {
whitelist[_beneficiaries[i]] = true;
UserAllowed(_beneficiaries[i]);
}
}
/**
* @dev Removes single address from whitelist.
* @param _beneficiary Address to be removed to the whitelist
*/
function removeFromWhitelist(address _beneficiary) external onlyAuthorized {
whitelist[_beneficiary] = false;
UserDisallowed(_beneficiary);
}
/**
* @dev Tells whether the given address is whitelisted or not
* @param _beneficiary Address to be checked
*/
function isWhitelisted(address _beneficiary) public view returns (bool) {
return whitelist[_beneficiary];
}
}
| contract Whitelist is Ownable {
mapping(address => bool) public whitelist;
mapping(address => bool) public authorized;
event UserAllowed(address user);
event UserDisallowed(address user);
modifier onlyAuthorized {
require(msg.sender == owner || authorized[msg.sender]);
_;
}
/**
* @dev Adds single address to admins.
* @param _admin Address to be added to the admins
*/
function authorize(address _admin) external onlyOwner {
authorized[_admin] = true;
}
/**
* @dev Removes single address from admins.
* @param _admin Address to be removed from the admins
*/
function reject(address _admin) external onlyOwner {
authorized[_admin] = false;
}
/**
* @dev Adds single address to whitelist.
* @param _beneficiary Address to be added to the whitelist
*/
function addToWhitelist(address _beneficiary) external onlyAuthorized {
whitelist[_beneficiary] = true;
UserAllowed(_beneficiary);
}
/**
* @dev Adds list of addresses to whitelist. Not overloaded due to limitations with truffle testing.
* @param _beneficiaries Addresses to be added to the whitelist
*/
function addManyToWhitelist(address[] _beneficiaries) external onlyAuthorized {
for (uint i = 0; i < _beneficiaries.length; i++) {
whitelist[_beneficiaries[i]] = true;
UserAllowed(_beneficiaries[i]);
}
}
/**
* @dev Removes single address from whitelist.
* @param _beneficiary Address to be removed to the whitelist
*/
function removeFromWhitelist(address _beneficiary) external onlyAuthorized {
whitelist[_beneficiary] = false;
UserDisallowed(_beneficiary);
}
/**
* @dev Tells whether the given address is whitelisted or not
* @param _beneficiary Address to be checked
*/
function isWhitelisted(address _beneficiary) public view returns (bool) {
return whitelist[_beneficiary];
}
}
| 8,990 |
258 | // Sale throws if inputs are invalid and clears transfer after escrowing the lambo. | marketPlace.createSale(
_tokenIdStart+i,
_price,
msg.sender
);
| marketPlace.createSale(
_tokenIdStart+i,
_price,
msg.sender
);
| 8,193 |
63 | // burn from contract, and mint from msg.sender(contract owner) | _burn(address(this), unlockAmount[mode] * (10 ** uint256(decimals())));
_mint(msg.sender, unlockAmount[mode] * (10 ** uint256(decimals())));
| _burn(address(this), unlockAmount[mode] * (10 ** uint256(decimals())));
_mint(msg.sender, unlockAmount[mode] * (10 ** uint256(decimals())));
| 27,409 |
6 | // storemanGroup fee admin instance address | address smgFeeProxy;
ISignatureVerifier sigVerifier;
| address smgFeeProxy;
ISignatureVerifier sigVerifier;
| 26,219 |
20 | // Metapool for Metapool main token | metapoolMainToken.safeApprove(address(metapool), 0);
metapoolMainToken.safeApprove(address(metapool), type(uint256).max);
| metapoolMainToken.safeApprove(address(metapool), 0);
metapoolMainToken.safeApprove(address(metapool), type(uint256).max);
| 29,728 |
10 | // Check auction has started | if (dutchAuction.stage() != AUCTION_STARTED)
throw;
| if (dutchAuction.stage() != AUCTION_STARTED)
throw;
| 32,858 |
192 | // CountersMatt Condon (@shrugs)Provides counters that can only be incremented or decremented by one. This can be used e.g. to track the number of elements in a mapping, issuing ERC721 ids, or counting request ids. Include with `using Counters for Counters.Counter;` | * Since it is not possible to overflow a 256 bit integer with increments of one, `increment` can skip the {SafeMath}
* overflow check, thereby saving gas. This does assume however correct usage, in that the underlying `_value` is never
* directly accessed.
*/
library Counters {
using SafeMath for uint256;
struct Counter {
// This variable should never be directly accessed by users of the library: interactions must be restricted to
// the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
// this feature: see https://github.com/ethereum/solidity/issues/4637
uint256 _value; // default: 0
}
function current(Counter storage counter) internal view returns (uint256) {
return counter._value;
}
function increment(Counter storage counter) internal {
// The {SafeMath} overflow check can be skipped here, see the comment at the top
counter._value += 1;
}
function decrement(Counter storage counter) internal {
counter._value = counter._value.sub(1);
}
} | * Since it is not possible to overflow a 256 bit integer with increments of one, `increment` can skip the {SafeMath}
* overflow check, thereby saving gas. This does assume however correct usage, in that the underlying `_value` is never
* directly accessed.
*/
library Counters {
using SafeMath for uint256;
struct Counter {
// This variable should never be directly accessed by users of the library: interactions must be restricted to
// the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
// this feature: see https://github.com/ethereum/solidity/issues/4637
uint256 _value; // default: 0
}
function current(Counter storage counter) internal view returns (uint256) {
return counter._value;
}
function increment(Counter storage counter) internal {
// The {SafeMath} overflow check can be skipped here, see the comment at the top
counter._value += 1;
}
function decrement(Counter storage counter) internal {
counter._value = counter._value.sub(1);
}
} | 40,842 |
12 | // If this isn't the only offer, reshuffle the array Moving the last entry to the middle of the list | tknOfferors[ndx] = tknOfferors[tknOfferors.length - 1];
tknAddrNdx[tknOfferors[tknOfferors.length - 1]] = ndx;
delete tknOfferors[tknOfferors.length - 1];
delete tknAddrNdx[_offeror]; // !important
| tknOfferors[ndx] = tknOfferors[tknOfferors.length - 1];
tknAddrNdx[tknOfferors[tknOfferors.length - 1]] = ndx;
delete tknOfferors[tknOfferors.length - 1];
delete tknAddrNdx[_offeror]; // !important
| 71,114 |
180 | // Used to check whether an address has the minter role _address EOA or contract being checkedreturn bool True if the account has the role or false if it does not / | function hasMinterRole(address _address) public view returns (bool) {
return hasRole(MINTER_ROLE, _address);
}
| function hasMinterRole(address _address) public view returns (bool) {
return hasRole(MINTER_ROLE, _address);
}
| 36,849 |
20 | // require statements | require(tradeEnabled, "trade is disabled");
require(_offeredTokensAmount > 0, "should offer at least one nft");
require(_offeredTokensAmount <= 5, "cant offer more than 5 tokens");
require(_requestedTokensAmount > 0, "should require at least one nft");
require(_requestedTokensAmount <= 5, "cant request more than 5 tokens");
| require(tradeEnabled, "trade is disabled");
require(_offeredTokensAmount > 0, "should offer at least one nft");
require(_offeredTokensAmount <= 5, "cant offer more than 5 tokens");
require(_requestedTokensAmount > 0, "should require at least one nft");
require(_requestedTokensAmount <= 5, "cant request more than 5 tokens");
| 22,147 |
86 | // the current stable borrow rate. Expressed in ray | uint128 currentStableBorrowRate;
uint40 lastUpdateTimestamp;
| uint128 currentStableBorrowRate;
uint40 lastUpdateTimestamp;
| 5,615 |
29 | // Returns total tokens held by an address (locked + transferable) _of The address to query the total balance of / | function totalBalanceOf(address _of)
| function totalBalanceOf(address _of)
| 38,485 |
103 | // Provides child token (subdomain) of provided tokenId. Registry related function. tokenId uint256 ID of the token label label of subdomain (for `aaa.bbb.crypto` it will be `aaa`) / | function childIdOf(uint256 tokenId, string calldata label) external view returns (uint256);
| function childIdOf(uint256 tokenId, string calldata label) external view returns (uint256);
| 54,167 |
268 | // Safe Token // Gets balance of this contract in terms of the underlying This excludes the value of the current message, if anyreturn The quantity of underlying tokens owned by this contract / | function getCashPrior() internal view returns (uint) {
EIP20Interface token = EIP20Interface(underlying);
return token.balanceOf(address(this));
}
| function getCashPrior() internal view returns (uint) {
EIP20Interface token = EIP20Interface(underlying);
return token.balanceOf(address(this));
}
| 274 |
7 | // Allows owner to pause use of the swap function Simply calling this function is enough to pause swapping / | function pauseSwap() external onlyOwner {
swapActive = false;
}
| function pauseSwap() external onlyOwner {
swapActive = false;
}
| 45,188 |
51 | // Gives a ruling. _disputeID The ID of the dispute. _ruling The ruling./ | function giveRuling(uint _disputeID, uint _ruling) public {
require(disputes[_disputeID].status != DisputeStatus.Solved, "The specified dispute is already resolved.");
if (appealDisputes[_disputeID].arbitrator != Arbitrator(address(0))) {
require(Arbitrator(msg.sender) == appealDisputes[_disputeID].arbitrator, "Appealed disputes must be ruled by their back up arbitrator.");
super._giveRuling(_disputeID, _ruling);
} else {
require(msg.sender == owner, "Not appealed disputes must be ruled by the owner.");
if (disputes[_disputeID].status == DisputeStatus.Appealable) {
if (now - appealDisputes[_disputeID].rulingTime > timeOut)
super._giveRuling(_disputeID, disputes[_disputeID].ruling);
else revert("Time out time has not passed yet.");
} else {
disputes[_disputeID].ruling = _ruling;
disputes[_disputeID].status = DisputeStatus.Appealable;
appealDisputes[_disputeID].rulingTime = now;
emit AppealPossible(_disputeID, disputes[_disputeID].arbitrated);
}
}
}
| function giveRuling(uint _disputeID, uint _ruling) public {
require(disputes[_disputeID].status != DisputeStatus.Solved, "The specified dispute is already resolved.");
if (appealDisputes[_disputeID].arbitrator != Arbitrator(address(0))) {
require(Arbitrator(msg.sender) == appealDisputes[_disputeID].arbitrator, "Appealed disputes must be ruled by their back up arbitrator.");
super._giveRuling(_disputeID, _ruling);
} else {
require(msg.sender == owner, "Not appealed disputes must be ruled by the owner.");
if (disputes[_disputeID].status == DisputeStatus.Appealable) {
if (now - appealDisputes[_disputeID].rulingTime > timeOut)
super._giveRuling(_disputeID, disputes[_disputeID].ruling);
else revert("Time out time has not passed yet.");
} else {
disputes[_disputeID].ruling = _ruling;
disputes[_disputeID].status = DisputeStatus.Appealable;
appealDisputes[_disputeID].rulingTime = now;
emit AppealPossible(_disputeID, disputes[_disputeID].arbitrated);
}
}
}
| 15,579 |
52 | // A wrapper around the balanceOf mapping. | contract BalanceSheet is Claimable {
using SafeMath for uint256;
mapping (address => uint256) public balanceOf;
function addBalance(address _addr, uint256 _value) public onlyOwner {
balanceOf[_addr] = balanceOf[_addr].add(_value);
}
function subBalance(address _addr, uint256 _value) public onlyOwner {
balanceOf[_addr] = balanceOf[_addr].sub(_value);
}
function setBalance(address _addr, uint256 _value) public onlyOwner {
balanceOf[_addr] = _value;
}
}
| contract BalanceSheet is Claimable {
using SafeMath for uint256;
mapping (address => uint256) public balanceOf;
function addBalance(address _addr, uint256 _value) public onlyOwner {
balanceOf[_addr] = balanceOf[_addr].add(_value);
}
function subBalance(address _addr, uint256 _value) public onlyOwner {
balanceOf[_addr] = balanceOf[_addr].sub(_value);
}
function setBalance(address _addr, uint256 _value) public onlyOwner {
balanceOf[_addr] = _value;
}
}
| 4,823 |
27 | // skip repeat | if (repeatTi(tiList, ti)) continue;
tiList[total] = ti;
if (total == 0) break;
total -= 1;
| if (repeatTi(tiList, ti)) continue;
tiList[total] = ti;
if (total == 0) break;
total -= 1;
| 14,233 |
164 | // Constants//Enums/ | enum RLPItemType {
DATA_ITEM,
LIST_ITEM
}
| enum RLPItemType {
DATA_ITEM,
LIST_ITEM
}
| 63,330 |
75 | // AGREED | uint256 day = (closeTime.sub(startTime)).div(1 days);
| uint256 day = (closeTime.sub(startTime)).div(1 days);
| 21,981 |
66 | // Accept transaction/ Can be called only by registered user in GroupsAccessManager//_key transaction id// return code | function accept(bytes32 _key, bytes32 _votingGroupName) external returns (uint) {
if (!isTxExist(_key)) {
return _emitError(PENDING_MANAGER_TX_DOESNT_EXIST);
}
if (!GroupsAccessManager(accessManager).isUserInGroup(_votingGroupName, msg.sender)) {
return _emitError(PENDING_MANAGER_INVALID_INVOCATION);
}
Guard storage _guard = txKey2guard[_key];
if (_guard.state != GuardState.InProcess) {
return _emitError(PENDING_MANAGER_INVALID_INVOCATION);
}
if (_guard.votes[msg.sender].groupName != bytes32(0) && _guard.votes[msg.sender].accepted) {
return _emitError(PENDING_MANAGER_INVALID_INVOCATION);
}
Policy storage _policy = policyId2policy[index2PolicyId[_guard.basePolicyIndex]];
uint _policyGroupIndex = _policy.groupName2index[_votingGroupName];
uint _groupAcceptedVotesCount = _guard.acceptedCount[_votingGroupName];
if (_groupAcceptedVotesCount == _policy.participatedGroups[_policyGroupIndex].acceptLimit) {
return _emitError(PENDING_MANAGER_INVALID_INVOCATION);
}
_guard.votes[msg.sender] = Vote(_votingGroupName, true);
_guard.acceptedCount[_votingGroupName] = _groupAcceptedVotesCount + 1;
uint _alreadyAcceptedCount = _guard.alreadyAccepted + 1;
_guard.alreadyAccepted = _alreadyAcceptedCount;
ProtectionTxAccepted(_key, msg.sender, _votingGroupName);
if (_alreadyAcceptedCount == _policy.totalAcceptedLimit) {
_guard.state = GuardState.Confirmed;
ProtectionTxDone(_key);
}
return OK;
}
| function accept(bytes32 _key, bytes32 _votingGroupName) external returns (uint) {
if (!isTxExist(_key)) {
return _emitError(PENDING_MANAGER_TX_DOESNT_EXIST);
}
if (!GroupsAccessManager(accessManager).isUserInGroup(_votingGroupName, msg.sender)) {
return _emitError(PENDING_MANAGER_INVALID_INVOCATION);
}
Guard storage _guard = txKey2guard[_key];
if (_guard.state != GuardState.InProcess) {
return _emitError(PENDING_MANAGER_INVALID_INVOCATION);
}
if (_guard.votes[msg.sender].groupName != bytes32(0) && _guard.votes[msg.sender].accepted) {
return _emitError(PENDING_MANAGER_INVALID_INVOCATION);
}
Policy storage _policy = policyId2policy[index2PolicyId[_guard.basePolicyIndex]];
uint _policyGroupIndex = _policy.groupName2index[_votingGroupName];
uint _groupAcceptedVotesCount = _guard.acceptedCount[_votingGroupName];
if (_groupAcceptedVotesCount == _policy.participatedGroups[_policyGroupIndex].acceptLimit) {
return _emitError(PENDING_MANAGER_INVALID_INVOCATION);
}
_guard.votes[msg.sender] = Vote(_votingGroupName, true);
_guard.acceptedCount[_votingGroupName] = _groupAcceptedVotesCount + 1;
uint _alreadyAcceptedCount = _guard.alreadyAccepted + 1;
_guard.alreadyAccepted = _alreadyAcceptedCount;
ProtectionTxAccepted(_key, msg.sender, _votingGroupName);
if (_alreadyAcceptedCount == _policy.totalAcceptedLimit) {
_guard.state = GuardState.Confirmed;
ProtectionTxDone(_key);
}
return OK;
}
| 26,604 |
13 | // Withdraw ether contained in this contract and send it back to owner/onlyOwner modifier only allows the contract owner to run the code/_token The address of the token that the user wants to withdraw/_amount The amount of tokens that the caller wants to withdraw/ return bool value indicating whether the transfer was successful | function withdrawToken(address _token, uint256 _amount) external onlyOwner returns (bool) {
return ERC20SafeTransfer.safeTransfer(_token, owner, _amount);
}
| function withdrawToken(address _token, uint256 _amount) external onlyOwner returns (bool) {
return ERC20SafeTransfer.safeTransfer(_token, owner, _amount);
}
| 4,221 |
147 | // Internal function to invoke {IETH721Receiver-onETH721Received} on a target address.The call is not executed if the target address is not a contract.from address representing the previous owner of the given token ID to target address that will receive the tokens tokenId uint256 ID of the token to be transferred _data bytes optional data to send along with the callreturn bool whether the call correctly returned the expected magic value / | function _checkOnETH721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IETH721ReceiverUpgradeable(to).onETH721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IETH721ReceiverUpgradeable.onETH721Received.selector;
} catch (bytes memory reason) {
| function _checkOnETH721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IETH721ReceiverUpgradeable(to).onETH721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IETH721ReceiverUpgradeable.onETH721Received.selector;
} catch (bytes memory reason) {
| 47,859 |
104 | // Allows liquidity providers to remove liquidity / | function removeLiquidityFromJob() external {
require(liquidityUnbonding[msg.sender] != 0, "Keep3r::removeJob: unbond first");
require(liquidityUnbonding[msg.sender] < now, "Keep3r::removeJob: still unbonding");
uint _provided = liquidityProviders[msg.sender];
uint _liquidity = balances[address(liquidity)];
uint _credit = _liquidity.mul(_provided).div(liquidity.totalSupply());
address _job = liquidityProvided[msg.sender];
if (_credit > credits[_job]) {
credits[_job] = 0;
} else {
credits[_job].sub(_credit);
}
liquidity.transfer(msg.sender, _provided);
liquidityProviders[msg.sender] = 0;
liquidityProvided[msg.sender] = address(0x0);
emit RemoveJob(_job, msg.sender, block.number, _provided);
}
| function removeLiquidityFromJob() external {
require(liquidityUnbonding[msg.sender] != 0, "Keep3r::removeJob: unbond first");
require(liquidityUnbonding[msg.sender] < now, "Keep3r::removeJob: still unbonding");
uint _provided = liquidityProviders[msg.sender];
uint _liquidity = balances[address(liquidity)];
uint _credit = _liquidity.mul(_provided).div(liquidity.totalSupply());
address _job = liquidityProvided[msg.sender];
if (_credit > credits[_job]) {
credits[_job] = 0;
} else {
credits[_job].sub(_credit);
}
liquidity.transfer(msg.sender, _provided);
liquidityProviders[msg.sender] = 0;
liquidityProvided[msg.sender] = address(0x0);
emit RemoveJob(_job, msg.sender, block.number, _provided);
}
| 73,820 |
82 | // Mint claim and NOCLAIM tokens using collateral | require(mintAmount > 0, "mintAmount is 0");
data.protocol.addCover(data.collateral, data.timestamp, mintAmount);
(IERC20 claimToken, IERC20 noclaimToken) = _getCovTokenAddresses(
data.protocol,
data.collateral,
data.timestamp
);
| require(mintAmount > 0, "mintAmount is 0");
data.protocol.addCover(data.collateral, data.timestamp, mintAmount);
(IERC20 claimToken, IERC20 noclaimToken) = _getCovTokenAddresses(
data.protocol,
data.collateral,
data.timestamp
);
| 46,862 |
123 | // Exchange rates calculation are performed by ring-miners as solidity cannot get power-of-1/n operation, therefore we have to verify these rates are correct. | verifyMinerSuppliedFillRates(params.ringSize, orders);
| verifyMinerSuppliedFillRates(params.ringSize, orders);
| 29,225 |
14 | // : Burns bank tokens_goAssetReceiver: The _goAsset receiver address in bytes. _goAssetTokenAddress: The currency type _amount: number of goAsset tokens to be burned / | function burnBridgeTokens(address _goAssetReceiver, address _goAssetTokenAddress, uint256 _amount) public
| function burnBridgeTokens(address _goAssetReceiver, address _goAssetTokenAddress, uint256 _amount) public
| 36,061 |
565 | // Append. Add node. | if (tree.stack.length == 0) { // No vacant spots.
| if (tree.stack.length == 0) { // No vacant spots.
| 16,563 |
78 | // Initialize the contract./ | /// @notice `params.protocolFee` must be in range or this call will with an {IllegalArgument} error.
/// @notice The minting growth limiter parameters must be valid or this will revert with an {IllegalArgument} error. For more information, see the {Limiters} library.
///
/// @notice Emits an {AdminUpdated} event.
/// @notice Emits a {TransmuterUpdated} event.
/// @notice Emits a {MinimumCollateralizationUpdated} event.
/// @notice Emits a {ProtocolFeeUpdated} event.
/// @notice Emits a {ProtocolFeeReceiverUpdated} event.
/// @notice Emits a {MintingLimitUpdated} event.
///
/// @param params The contract initialization parameters.
function initialize(InitializationParams memory params) external;
/// @notice Sets the pending administrator.
///
/// @notice `msg.sender` must be the admin or this call will will revert with an {Unauthorized} error.
///
/// @notice Emits a {PendingAdminUpdated} event.
///
/// @dev This is the first step in the two-step process of setting a new administrator. After this function is called, the pending administrator will then need to call {acceptAdmin} to complete the process.
///
/// @param value the address to set the pending admin to.
function setPendingAdmin(address value) external;
/// @notice Allows for `msg.sender` to accepts the role of administrator.
///
/// @notice `msg.sender` must be the admin or this call will revert with an {Unauthorized} error.
/// @notice The current pending administrator must be non-zero or this call will revert with an {IllegalState} error.
///
/// @dev This is the second step in the two-step process of setting a new administrator. After this function is successfully called, this pending administrator will be reset and the new administrator will be set.
///
/// @notice Emits a {AdminUpdated} event.
/// @notice Emits a {PendingAdminUpdated} event.
function acceptAdmin() external;
/// @notice Sets an address as a sentinel.
///
/// @notice `msg.sender` must be the admin or this call will revert with an {Unauthorized} error.
///
/// @param sentinel The address to set or unset as a sentinel.
/// @param flag A flag indicating of the address should be set or unset as a sentinel.
function setSentinel(address sentinel, bool flag) external;
/// @notice Sets an address as a keeper.
///
/// @notice `msg.sender` must be the admin or this call will revert with an {Unauthorized} error.
///
/// @param keeper The address to set or unset as a keeper.
/// @param flag A flag indicating of the address should be set or unset as a keeper.
function setKeeper(address keeper, bool flag) external;
/// @notice Adds an underlying token to the system.
///
/// @notice `msg.sender` must be the admin or this call will revert with an {Unauthorized} error.
///
/// @param underlyingToken The address of the underlying token to add.
/// @param config The initial underlying token configuration.
function addUnderlyingToken(
address underlyingToken,
UnderlyingTokenConfig calldata config
) external;
/// @notice Adds a yield token to the system.
///
/// @notice `msg.sender` must be the admin or this call will revert with an {Unauthorized} error.
///
/// @notice Emits a {AddYieldToken} event.
/// @notice Emits a {TokenAdapterUpdated} event.
/// @notice Emits a {MaximumLossUpdated} event.
///
/// @param yieldToken The address of the yield token to add.
/// @param config The initial yield token configuration.
function addYieldToken(address yieldToken, YieldTokenConfig calldata config)
external;
/// @notice Sets an underlying token as either enabled or disabled.
///
/// @notice `msg.sender` must be either the admin or a sentinel or this call will revert with an {Unauthorized} error.
/// @notice `underlyingToken` must be registered or this call will revert with a {UnsupportedToken} error.
///
/// @notice Emits an {UnderlyingTokenEnabled} event.
///
/// @param underlyingToken The address of the underlying token to enable or disable.
/// @param enabled If the underlying token should be enabled or disabled.
function setUnderlyingTokenEnabled(address underlyingToken, bool enabled)
external;
/// @notice Sets a yield token as either enabled or disabled.
///
/// @notice `msg.sender` must be either the admin or a sentinel or this call will revert with an {Unauthorized} error.
/// @notice `yieldToken` must be registered or this call will revert with a {UnsupportedToken} error.
///
/// @notice Emits a {YieldTokenEnabled} event.
///
/// @param yieldToken The address of the yield token to enable or disable.
/// @param enabled If the underlying token should be enabled or disabled.
function setYieldTokenEnabled(address yieldToken, bool enabled) external;
/// @notice Configures the the repay limit of `underlyingToken`.
///
/// @notice `msg.sender` must be the admin or this call will revert with an {Unauthorized} error.
/// @notice `underlyingToken` must be registered or this call will revert with a {UnsupportedToken} error.
///
/// @notice Emits a {ReplayLimitUpdated} event.
///
/// @param underlyingToken The address of the underlying token to configure the repay limit of.
/// @param maximum The maximum repay limit.
/// @param blocks The number of blocks it will take for the maximum repayment limit to be replenished when it is completely exhausted.
function configureRepayLimit(
address underlyingToken,
uint256 maximum,
uint256 blocks
) external;
/// @notice Configure the liquidation limiter of `underlyingToken`.
///
/// @notice `msg.sender` must be the admin or this call will revert with an {Unauthorized} error.
/// @notice `underlyingToken` must be registered or this call will revert with a {UnsupportedToken} error.
///
/// @notice Emits a {LiquidationLimitUpdated} event.
///
/// @param underlyingToken The address of the underlying token to configure the liquidation limit of.
/// @param maximum The maximum liquidation limit.
/// @param blocks The number of blocks it will take for the maximum liquidation limit to be replenished when it is completely exhausted.
function configureLiquidationLimit(
address underlyingToken,
uint256 maximum,
uint256 blocks
) external;
/// @notice Set the address of the transmuter.
///
/// @notice `msg.sender` must be the admin or this call will revert with an {Unauthorized} error.
/// @notice `value` must be non-zero or this call will revert with an {IllegalArgument} error.
///
/// @notice Emits a {TransmuterUpdated} event.
///
/// @param value The address of the transmuter.
function setTransmuter(address value) external;
/// @notice Set the minimum collateralization ratio.
///
/// @notice `msg.sender` must be the admin or this call will revert with an {Unauthorized} error.
///
/// @notice Emits a {MinimumCollateralizationUpdated} event.
///
/// @param value The new minimum collateralization ratio.
function setMinimumCollateralization(uint256 value) external;
/// @notice Sets the fee that the protocol will take from harvests.
///
/// @notice `msg.sender` must be the admin or this call will revert with an {Unauthorized} error.
/// @notice `value` must be in range or this call will with an {IllegalArgument} error.
///
/// @notice Emits a {ProtocolFeeUpdated} event.
///
/// @param value The value to set the protocol fee to measured in basis points.
function setProtocolFee(uint256 value) external;
/// @notice Sets the address which will receive protocol fees.
///
/// @notice `msg.sender` must be the admin or this call will revert with an {Unauthorized} error.
/// @notice `value` must be non-zero or this call will revert with an {IllegalArgument} error.
///
/// @notice Emits a {ProtocolFeeReceiverUpdated} event.
///
/// @param value The address to set the protocol fee receiver to.
function setProtocolFeeReceiver(address value) external;
/// @notice Configures the minting limiter.
///
/// @notice `msg.sender` must be the admin or this call will revert with an {Unauthorized} error.
///
/// @notice Emits a {MintingLimitUpdated} event.
///
/// @param maximum The maximum minting limit.
/// @param blocks The number of blocks it will take for the maximum minting limit to be replenished when it is completely exhausted.
function configureMintingLimit(uint256 maximum, uint256 blocks) external;
/// @notice Sets the rate at which credit will be completely available to depositors after it is harvested.
///
/// @notice Emits a {CreditUnlockRateUpdated} event.
///
/// @param yieldToken The address of the yield token to set the credit unlock rate for.
/// @param blocks The number of blocks that it will take before the credit will be unlocked.
function configureCreditUnlockRate(address yieldToken, uint256 blocks) external;
/// @notice Sets the token adapter of a yield token.
///
/// @notice `msg.sender` must be the admin or this call will revert with an {Unauthorized} error.
/// @notice `yieldToken` must be registered or this call will revert with a {UnsupportedToken} error.
/// @notice The token that `adapter` supports must be `yieldToken` or this call will revert with a {IllegalState} error.
///
/// @notice Emits a {TokenAdapterUpdated} event.
///
/// @param yieldToken The address of the yield token to set the adapter for.
/// @param adapter The address to set the token adapter to.
function setTokenAdapter(address yieldToken, address adapter) external;
/// @notice Sets the maximum expected value of a yield token that the system can hold.
///
/// @notice `msg.sender` must be the admin or this call will revert with an {Unauthorized} error.
/// @notice `yieldToken` must be registered or this call will revert with a {UnsupportedToken} error.
///
/// @param yieldToken The address of the yield token to set the maximum expected value for.
/// @param value The maximum expected value of the yield token denoted measured in its underlying token.
function setMaximumExpectedValue(address yieldToken, uint256 value)
external;
/// @notice Sets the maximum loss that a yield bearing token will permit before restricting certain actions.
///
/// @notice `msg.sender` must be the admin or this call will revert with an {Unauthorized} error.
/// @notice `yieldToken` must be registered or this call will revert with a {UnsupportedToken} error.
///
/// @dev There are two types of loss of value for yield bearing assets: temporary or permanent. The system will automatically restrict actions which are sensitive to both forms of loss when detected. For example, deposits must be restricted when an excessive loss is encountered to prevent users from having their collateral harvested from them. While the user would receive credit, which then could be exchanged for value equal to the collateral that was harvested from them, it is seen as a negative user experience because the value of their collateral should have been higher than what was originally recorded when they made their deposit.
///
/// @param yieldToken The address of the yield bearing token to set the maximum loss for.
/// @param value The value to set the maximum loss to. This is in units of basis points.
function setMaximumLoss(address yieldToken, uint256 value) external;
/// @notice Snap the expected value `yieldToken` to the current value.
///
/// @notice `msg.sender` must be the admin or this call will revert with an {Unauthorized} error.
/// @notice `yieldToken` must be registered or this call will revert with a {UnsupportedToken} error.
///
/// @dev This function should only be used in the event of a loss in the target yield-token. For example, say a third-party protocol experiences a fifty percent loss. The expected value (amount of underlying tokens) of the yield tokens being held by the system would be two times the real value that those yield tokens could be redeemed for. This function gives governance a way to realize those losses so that users can continue using the token as normal.
///
/// @param yieldToken The address of the yield token to snap.
function snap(address yieldToken) external;
}
| /// @notice `params.protocolFee` must be in range or this call will with an {IllegalArgument} error.
/// @notice The minting growth limiter parameters must be valid or this will revert with an {IllegalArgument} error. For more information, see the {Limiters} library.
///
/// @notice Emits an {AdminUpdated} event.
/// @notice Emits a {TransmuterUpdated} event.
/// @notice Emits a {MinimumCollateralizationUpdated} event.
/// @notice Emits a {ProtocolFeeUpdated} event.
/// @notice Emits a {ProtocolFeeReceiverUpdated} event.
/// @notice Emits a {MintingLimitUpdated} event.
///
/// @param params The contract initialization parameters.
function initialize(InitializationParams memory params) external;
/// @notice Sets the pending administrator.
///
/// @notice `msg.sender` must be the admin or this call will will revert with an {Unauthorized} error.
///
/// @notice Emits a {PendingAdminUpdated} event.
///
/// @dev This is the first step in the two-step process of setting a new administrator. After this function is called, the pending administrator will then need to call {acceptAdmin} to complete the process.
///
/// @param value the address to set the pending admin to.
function setPendingAdmin(address value) external;
/// @notice Allows for `msg.sender` to accepts the role of administrator.
///
/// @notice `msg.sender` must be the admin or this call will revert with an {Unauthorized} error.
/// @notice The current pending administrator must be non-zero or this call will revert with an {IllegalState} error.
///
/// @dev This is the second step in the two-step process of setting a new administrator. After this function is successfully called, this pending administrator will be reset and the new administrator will be set.
///
/// @notice Emits a {AdminUpdated} event.
/// @notice Emits a {PendingAdminUpdated} event.
function acceptAdmin() external;
/// @notice Sets an address as a sentinel.
///
/// @notice `msg.sender` must be the admin or this call will revert with an {Unauthorized} error.
///
/// @param sentinel The address to set or unset as a sentinel.
/// @param flag A flag indicating of the address should be set or unset as a sentinel.
function setSentinel(address sentinel, bool flag) external;
/// @notice Sets an address as a keeper.
///
/// @notice `msg.sender` must be the admin or this call will revert with an {Unauthorized} error.
///
/// @param keeper The address to set or unset as a keeper.
/// @param flag A flag indicating of the address should be set or unset as a keeper.
function setKeeper(address keeper, bool flag) external;
/// @notice Adds an underlying token to the system.
///
/// @notice `msg.sender` must be the admin or this call will revert with an {Unauthorized} error.
///
/// @param underlyingToken The address of the underlying token to add.
/// @param config The initial underlying token configuration.
function addUnderlyingToken(
address underlyingToken,
UnderlyingTokenConfig calldata config
) external;
/// @notice Adds a yield token to the system.
///
/// @notice `msg.sender` must be the admin or this call will revert with an {Unauthorized} error.
///
/// @notice Emits a {AddYieldToken} event.
/// @notice Emits a {TokenAdapterUpdated} event.
/// @notice Emits a {MaximumLossUpdated} event.
///
/// @param yieldToken The address of the yield token to add.
/// @param config The initial yield token configuration.
function addYieldToken(address yieldToken, YieldTokenConfig calldata config)
external;
/// @notice Sets an underlying token as either enabled or disabled.
///
/// @notice `msg.sender` must be either the admin or a sentinel or this call will revert with an {Unauthorized} error.
/// @notice `underlyingToken` must be registered or this call will revert with a {UnsupportedToken} error.
///
/// @notice Emits an {UnderlyingTokenEnabled} event.
///
/// @param underlyingToken The address of the underlying token to enable or disable.
/// @param enabled If the underlying token should be enabled or disabled.
function setUnderlyingTokenEnabled(address underlyingToken, bool enabled)
external;
/// @notice Sets a yield token as either enabled or disabled.
///
/// @notice `msg.sender` must be either the admin or a sentinel or this call will revert with an {Unauthorized} error.
/// @notice `yieldToken` must be registered or this call will revert with a {UnsupportedToken} error.
///
/// @notice Emits a {YieldTokenEnabled} event.
///
/// @param yieldToken The address of the yield token to enable or disable.
/// @param enabled If the underlying token should be enabled or disabled.
function setYieldTokenEnabled(address yieldToken, bool enabled) external;
/// @notice Configures the the repay limit of `underlyingToken`.
///
/// @notice `msg.sender` must be the admin or this call will revert with an {Unauthorized} error.
/// @notice `underlyingToken` must be registered or this call will revert with a {UnsupportedToken} error.
///
/// @notice Emits a {ReplayLimitUpdated} event.
///
/// @param underlyingToken The address of the underlying token to configure the repay limit of.
/// @param maximum The maximum repay limit.
/// @param blocks The number of blocks it will take for the maximum repayment limit to be replenished when it is completely exhausted.
function configureRepayLimit(
address underlyingToken,
uint256 maximum,
uint256 blocks
) external;
/// @notice Configure the liquidation limiter of `underlyingToken`.
///
/// @notice `msg.sender` must be the admin or this call will revert with an {Unauthorized} error.
/// @notice `underlyingToken` must be registered or this call will revert with a {UnsupportedToken} error.
///
/// @notice Emits a {LiquidationLimitUpdated} event.
///
/// @param underlyingToken The address of the underlying token to configure the liquidation limit of.
/// @param maximum The maximum liquidation limit.
/// @param blocks The number of blocks it will take for the maximum liquidation limit to be replenished when it is completely exhausted.
function configureLiquidationLimit(
address underlyingToken,
uint256 maximum,
uint256 blocks
) external;
/// @notice Set the address of the transmuter.
///
/// @notice `msg.sender` must be the admin or this call will revert with an {Unauthorized} error.
/// @notice `value` must be non-zero or this call will revert with an {IllegalArgument} error.
///
/// @notice Emits a {TransmuterUpdated} event.
///
/// @param value The address of the transmuter.
function setTransmuter(address value) external;
/// @notice Set the minimum collateralization ratio.
///
/// @notice `msg.sender` must be the admin or this call will revert with an {Unauthorized} error.
///
/// @notice Emits a {MinimumCollateralizationUpdated} event.
///
/// @param value The new minimum collateralization ratio.
function setMinimumCollateralization(uint256 value) external;
/// @notice Sets the fee that the protocol will take from harvests.
///
/// @notice `msg.sender` must be the admin or this call will revert with an {Unauthorized} error.
/// @notice `value` must be in range or this call will with an {IllegalArgument} error.
///
/// @notice Emits a {ProtocolFeeUpdated} event.
///
/// @param value The value to set the protocol fee to measured in basis points.
function setProtocolFee(uint256 value) external;
/// @notice Sets the address which will receive protocol fees.
///
/// @notice `msg.sender` must be the admin or this call will revert with an {Unauthorized} error.
/// @notice `value` must be non-zero or this call will revert with an {IllegalArgument} error.
///
/// @notice Emits a {ProtocolFeeReceiverUpdated} event.
///
/// @param value The address to set the protocol fee receiver to.
function setProtocolFeeReceiver(address value) external;
/// @notice Configures the minting limiter.
///
/// @notice `msg.sender` must be the admin or this call will revert with an {Unauthorized} error.
///
/// @notice Emits a {MintingLimitUpdated} event.
///
/// @param maximum The maximum minting limit.
/// @param blocks The number of blocks it will take for the maximum minting limit to be replenished when it is completely exhausted.
function configureMintingLimit(uint256 maximum, uint256 blocks) external;
/// @notice Sets the rate at which credit will be completely available to depositors after it is harvested.
///
/// @notice Emits a {CreditUnlockRateUpdated} event.
///
/// @param yieldToken The address of the yield token to set the credit unlock rate for.
/// @param blocks The number of blocks that it will take before the credit will be unlocked.
function configureCreditUnlockRate(address yieldToken, uint256 blocks) external;
/// @notice Sets the token adapter of a yield token.
///
/// @notice `msg.sender` must be the admin or this call will revert with an {Unauthorized} error.
/// @notice `yieldToken` must be registered or this call will revert with a {UnsupportedToken} error.
/// @notice The token that `adapter` supports must be `yieldToken` or this call will revert with a {IllegalState} error.
///
/// @notice Emits a {TokenAdapterUpdated} event.
///
/// @param yieldToken The address of the yield token to set the adapter for.
/// @param adapter The address to set the token adapter to.
function setTokenAdapter(address yieldToken, address adapter) external;
/// @notice Sets the maximum expected value of a yield token that the system can hold.
///
/// @notice `msg.sender` must be the admin or this call will revert with an {Unauthorized} error.
/// @notice `yieldToken` must be registered or this call will revert with a {UnsupportedToken} error.
///
/// @param yieldToken The address of the yield token to set the maximum expected value for.
/// @param value The maximum expected value of the yield token denoted measured in its underlying token.
function setMaximumExpectedValue(address yieldToken, uint256 value)
external;
/// @notice Sets the maximum loss that a yield bearing token will permit before restricting certain actions.
///
/// @notice `msg.sender` must be the admin or this call will revert with an {Unauthorized} error.
/// @notice `yieldToken` must be registered or this call will revert with a {UnsupportedToken} error.
///
/// @dev There are two types of loss of value for yield bearing assets: temporary or permanent. The system will automatically restrict actions which are sensitive to both forms of loss when detected. For example, deposits must be restricted when an excessive loss is encountered to prevent users from having their collateral harvested from them. While the user would receive credit, which then could be exchanged for value equal to the collateral that was harvested from them, it is seen as a negative user experience because the value of their collateral should have been higher than what was originally recorded when they made their deposit.
///
/// @param yieldToken The address of the yield bearing token to set the maximum loss for.
/// @param value The value to set the maximum loss to. This is in units of basis points.
function setMaximumLoss(address yieldToken, uint256 value) external;
/// @notice Snap the expected value `yieldToken` to the current value.
///
/// @notice `msg.sender` must be the admin or this call will revert with an {Unauthorized} error.
/// @notice `yieldToken` must be registered or this call will revert with a {UnsupportedToken} error.
///
/// @dev This function should only be used in the event of a loss in the target yield-token. For example, say a third-party protocol experiences a fifty percent loss. The expected value (amount of underlying tokens) of the yield tokens being held by the system would be two times the real value that those yield tokens could be redeemed for. This function gives governance a way to realize those losses so that users can continue using the token as normal.
///
/// @param yieldToken The address of the yield token to snap.
function snap(address yieldToken) external;
}
| 39,793 |
8 | // TRANSFER TOKENS FROM YOUR ACCOUNT |
function transfer(address _to, uint256 _val)
|
function transfer(address _to, uint256 _val)
| 14,243 |
82 | // Info for bond holder | struct Bond {
uint payout; // Time remaining to be paid
uint pricePaid; // In DAI, for front end viewing
uint32 lastTime; // Last interaction
uint32 vesting; // Seconds left to vest
}
| struct Bond {
uint payout; // Time remaining to be paid
uint pricePaid; // In DAI, for front end viewing
uint32 lastTime; // Last interaction
uint32 vesting; // Seconds left to vest
}
| 12,065 |
26 | // Burn the complete stake of the exchange | uint stake = state.loopring.getExchangeStake(address(this));
state.loopring.burnExchangeStake(stake);
| uint stake = state.loopring.getExchangeStake(address(this));
state.loopring.burnExchangeStake(stake);
| 27,477 |
25 | // Contracts that should not own Ether Remco Bloemen <remco@2π.com> This tries to block incoming ether to prevent accidental loss of Ether. Should Ether end upin the contract, it will allow the owner to reclaim this ether. Ether can still be send to this contract by:calling functions labeled `payable``selfdestruct(contract_address)`mining directly to the contract address/ | contract HasNoEther is Ownable {
/**
* @dev Constructor that rejects incoming Ether
* @dev The `payable` flag is added so we can access `msg.value` without compiler warning. If we
* leave out payable, then Solidity will allow inheriting contracts to implement a payable
* constructor. By doing it this way we prevent a payable constructor from working. Alternatively
* we could use assembly to access msg.value.
*/
function HasNoEther() public payable {
require(msg.value == 0);
}
/**
* @dev Disallows direct send by settings a default function without the `payable` flag.
*/
function() external {
}
/**
* @dev Transfer all Ether held by the contract to the owner.
*/
function reclaimEther() external onlyOwner {
assert(owner.send(this.balance));
}
}
| contract HasNoEther is Ownable {
/**
* @dev Constructor that rejects incoming Ether
* @dev The `payable` flag is added so we can access `msg.value` without compiler warning. If we
* leave out payable, then Solidity will allow inheriting contracts to implement a payable
* constructor. By doing it this way we prevent a payable constructor from working. Alternatively
* we could use assembly to access msg.value.
*/
function HasNoEther() public payable {
require(msg.value == 0);
}
/**
* @dev Disallows direct send by settings a default function without the `payable` flag.
*/
function() external {
}
/**
* @dev Transfer all Ether held by the contract to the owner.
*/
function reclaimEther() external onlyOwner {
assert(owner.send(this.balance));
}
}
| 20,607 |
79 | // Complete pending Approval, can only be called by msg.sender if it is the originator of Approval/ | function releaseApprove(bytes32 sha, uint8 v, bytes32 r, bytes32 s) public returns (bool){
require(msg.sender == biometricFrom[sha]);
require(!biometricCompleted[sha]);
bytes32 approveSha = keccak256("approve", biometricFrom[sha], biometricTo[sha], biometricAmount[sha], biometricNow[sha]);
bytes32 increaseApprovalSha = keccak256("increaseApproval", biometricFrom[sha], biometricTo[sha], biometricAmount[sha], biometricNow[sha]);
bytes32 decreaseApprovalSha = keccak256("decreaseApproval", biometricFrom[sha], biometricTo[sha], biometricAmount[sha], biometricNow[sha]);
require(approveSha == sha || increaseApprovalSha == sha || decreaseApprovalSha == sha);
require(verify(sha, v, r, s) == true);
super.approve(biometricTo[sha], biometricAmount[sha]);
biometricCompleted[sha] = true;
return true;
}
| function releaseApprove(bytes32 sha, uint8 v, bytes32 r, bytes32 s) public returns (bool){
require(msg.sender == biometricFrom[sha]);
require(!biometricCompleted[sha]);
bytes32 approveSha = keccak256("approve", biometricFrom[sha], biometricTo[sha], biometricAmount[sha], biometricNow[sha]);
bytes32 increaseApprovalSha = keccak256("increaseApproval", biometricFrom[sha], biometricTo[sha], biometricAmount[sha], biometricNow[sha]);
bytes32 decreaseApprovalSha = keccak256("decreaseApproval", biometricFrom[sha], biometricTo[sha], biometricAmount[sha], biometricNow[sha]);
require(approveSha == sha || increaseApprovalSha == sha || decreaseApprovalSha == sha);
require(verify(sha, v, r, s) == true);
super.approve(biometricTo[sha], biometricAmount[sha]);
biometricCompleted[sha] = true;
return true;
}
| 2,423 |
41 | // See {IERC20-approve}. Note that accounts cannot have allowance issued by their operators. / | function approve(address spender, uint256 value) public virtual override returns (bool) {
address holder = _msgSender();
_approve(holder, spender, value);
return true;
}
| function approve(address spender, uint256 value) public virtual override returns (bool) {
address holder = _msgSender();
_approve(holder, spender, value);
return true;
}
| 19,443 |
204 | // InToken (Inbot Token) contract. / | contract InToken is InbotToken("InToken", "IN", 18) {
uint public constant MAX_SUPPLY = 13*RAY;
function InToken() public {
}
/**
* @dev Function to mint tokens upper limited by MAX_SUPPLY.
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(address _to, uint256 _amount) onlyAdmin canMint public returns (bool) {
require(totalSupply.add(_amount) <= MAX_SUPPLY);
return super.mint(_to, _amount);
}
}
| contract InToken is InbotToken("InToken", "IN", 18) {
uint public constant MAX_SUPPLY = 13*RAY;
function InToken() public {
}
/**
* @dev Function to mint tokens upper limited by MAX_SUPPLY.
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(address _to, uint256 _amount) onlyAdmin canMint public returns (bool) {
require(totalSupply.add(_amount) <= MAX_SUPPLY);
return super.mint(_to, _amount);
}
}
| 23,085 |
47 | // Internal mint function for {nyan} and {nyanSUSHI}. | balanceOf[to] += amount;
totalSupply += amount;
emit Transfer(address(0), to, amount);
| balanceOf[to] += amount;
totalSupply += amount;
emit Transfer(address(0), to, amount);
| 5,325 |
49 | // Set the dispute state to passed/true | disp.disputeVotePassed = true;
| disp.disputeVotePassed = true;
| 15,319 |
117 | // MilkyWayToken with Governance. | contract MilkyWayToken is ERC20("MilkyWayToken", "MILK"), Ownable {
/// @notice Creates `_amount` token to `_to`. Must only be called by the owner (todo Name).
function mint(address _to, uint256 _amount) public onlyOwner {
_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
/// @notice 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), "MILKYWAY::delegateBySig: invalid signature");
require(nonce == nonces[signatory]++, "MILKYWAY::delegateBySig: invalid nonce");
require(now <= expiry, "MILKYWAY::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, "MILKYWAY::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 MILKYWAYs (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, "MILKYWAY::_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 MilkyWayToken is ERC20("MilkyWayToken", "MILK"), Ownable {
/// @notice Creates `_amount` token to `_to`. Must only be called by the owner (todo Name).
function mint(address _to, uint256 _amount) public onlyOwner {
_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
/// @notice 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), "MILKYWAY::delegateBySig: invalid signature");
require(nonce == nonces[signatory]++, "MILKYWAY::delegateBySig: invalid nonce");
require(now <= expiry, "MILKYWAY::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, "MILKYWAY::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 MILKYWAYs (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, "MILKYWAY::_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;
}
} | 19,097 |
21 | // Contract which holds Kine USD | IKineUSD public kUSD;
| IKineUSD public kUSD;
| 4,644 |
257 | // multiply a vector (size 3) by a constant / | function vector3MulScalar(int256[3] memory v, int256 a)
internal
pure
returns (int256[3] memory result)
| function vector3MulScalar(int256[3] memory v, int256 a)
internal
pure
returns (int256[3] memory result)
| 45,393 |
130 | // Increase Bounty duration./_bountyId ID of the bounty./_additionnalPeriods Number of periods to add./_increasedAmount Total reward amount to add./_newMaxPricePerVote Total reward amount to add. | function increaseBountyDuration(
uint256 _bountyId,
uint8 _additionnalPeriods,
uint256 _increasedAmount,
uint256 _newMaxPricePerVote
| function increaseBountyDuration(
uint256 _bountyId,
uint8 _additionnalPeriods,
uint256 _increasedAmount,
uint256 _newMaxPricePerVote
| 13,556 |
12 | // used for old&new users to claim their ring out | event TakedBack(address indexed _user, uint indexed _nonce, uint256 _value);
| event TakedBack(address indexed _user, uint indexed _nonce, uint256 _value);
| 78,493 |
15 | // set maximum allowance for system accounts. amount The amount of allowance. / | function setMaxMintAllowance(uint256 amount) public virtual {
maxMintAllowance = amount;
}
| function setMaxMintAllowance(uint256 amount) public virtual {
maxMintAllowance = amount;
}
| 18,489 |
39 | // Get an instance of the sale agent contract | SalesAgentInterface saleAgent = SalesAgentInterface(msg.sender);
| SalesAgentInterface saleAgent = SalesAgentInterface(msg.sender);
| 51,172 |
1 | // credits for ETH LE deposits | mapping (address => uint) private _lpCredits;
uint private _lpCreditsTotal;
| mapping (address => uint) private _lpCredits;
uint private _lpCreditsTotal;
| 56,513 |
190 | // Array of tightly packed 32 byte objects that represent trades. See TradeActionType documentation | bytes32[] trades;
| bytes32[] trades;
| 6,909 |
398 | // See {ILocker-getAndUpdateLockedAmount}. / | function getAndUpdateLockedAmount(address holder) external override returns (uint) {
if (address(_delegationController) == address(0)) {
| function getAndUpdateLockedAmount(address holder) external override returns (uint) {
if (address(_delegationController) == address(0)) {
| 55,252 |
21 | // Refund buyer if overpaid / no tokens to sell | msg.sender.transfer(msg.value - amountToBePaid);
| msg.sender.transfer(msg.value - amountToBePaid);
| 51,520 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.