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
|
---|---|---|---|---|
119 | // APR | function getCompoundAPR(address _token) public view returns (uint256) {
return Compound(_token).supplyRatePerBlock().mul(2102400);
}
| function getCompoundAPR(address _token) public view returns (uint256) {
return Compound(_token).supplyRatePerBlock().mul(2102400);
}
| 24,442 |
109 | // If true, transfers from IUniswapV2Pair at address `addr` will mint an extra `_interestRatePerBuyThousandth`/1000 DIV tokens per 1 Token for the recipient./addr Address to check/it is not trivial to return a mapping without incurring further storage costs | function isAddressUniswapAddress(address addr) external view returns (bool) {
return _UniswapAddresses[addr];
}
| function isAddressUniswapAddress(address addr) external view returns (bool) {
return _UniswapAddresses[addr];
}
| 71,738 |
341 | // Check that the warrior exists. | warrior.identity != 0 &&
| warrior.identity != 0 &&
| 24,132 |
525 | // Deposits waTokens into the transmuter// amount the amount of waTokens to stake | function stake(uint256 amount)
public
runPhasedDistribution()
updateAccount(msg.sender)
checkIfNewUser()
| function stake(uint256 amount)
public
runPhasedDistribution()
updateAccount(msg.sender)
checkIfNewUser()
| 18,499 |
19 | // Internal function that returns the initialized version. Returns `_initialized` / | function _getInitializedVersion() internal view returns (uint256) {
return _initialized;
}
| function _getInitializedVersion() internal view returns (uint256) {
return _initialized;
}
| 25,162 |
0 | // Execute ERC20 transferFrom currency Currency address from Sender address to Recipient address amount Amount to transfer / | function _executeERC20TransferFrom(address currency, address from, address to, uint256 amount) internal {
if (currency.code.length == 0) {
revert NotAContract();
}
| function _executeERC20TransferFrom(address currency, address from, address to, uint256 amount) internal {
if (currency.code.length == 0) {
revert NotAContract();
}
| 46,366 |
374 | // round 20 | ark(i, q, 6172482022646932735745595886795230725225293469762393889050804649558459236626);
sbox_partial(i, q);
mix(i, q);
| ark(i, q, 6172482022646932735745595886795230725225293469762393889050804649558459236626);
sbox_partial(i, q);
mix(i, q);
| 51,200 |
764 | // Deploys and returns the address of a clone that mimics the behaviour of `implementation`. This function uses the create2 opcode and a `salt` to deterministically deploythe clone. Using the same `implementation` and `salt` multiple time will revert, sincethe clones cannot be deployed twice at the same address. / | function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) {
assembly {
let ptr := mload(0x40)
mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
mstore(add(ptr, 0x14), shl(0x60, implementation))
mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
instance := create2(0, ptr, 0x37, salt)
}
require(instance != address(0), "ERC1167: create2 failed");
}
| function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) {
assembly {
let ptr := mload(0x40)
mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
mstore(add(ptr, 0x14), shl(0x60, implementation))
mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
instance := create2(0, ptr, 0x37, salt)
}
require(instance != address(0), "ERC1167: create2 failed");
}
| 11,438 |
101 | // Emit event that a proposal has been voted for. | emit Vote(id);
| emit Vote(id);
| 12,653 |
22 | // Allows a Lock manager to add or remove an event hook / | function setEventHooks(
| function setEventHooks(
| 12,802 |
86 | // this is the main battle function of the contract, it takes the card address you wish to claim as well as your card choices as input. a lot of complex calculations happen within this function and in the end, a result will be determined on whether you won the claim or not. at the end, an event will be logged with all of the information about what happened in the battle including the final result, the contenders, the card choices (yours and your opponenets) as well as the final attack and defence numbers. this function will revert if the msg.value | function attemptToClaimCard(address cardAddress, address[3] choices) public payable {
// a lot of the functionality of attemptToClaimCard() is calculated in other methods as
// there is only a 16 local variable limit per method and we need a lot more than that
// see ownerCanClaimCard() below, this ensures we can actually claim the card we are after
// by running through various requirement checks
address claimContender;
uint256 claimContenderIndex;
(claimContender, claimContenderIndex) = ownerCanClaimCard(msg.sender, cardAddress, choices, msg.value);
address[3] memory opponentCardChoices = generateCardsFromClaimForOpponent(cardAddress, claimContender);
uint256[3][2] memory allFinalAttackFigures;
uint256[3][2] memory allFinalDefenceFigures;
(allFinalAttackFigures, allFinalDefenceFigures) = calculateAdjustedFiguresForBattle(choices, opponentCardChoices);
// after this point we have all of the modified attack and defence figures
// in the arrays above. the way the winner is determined is by counting
// how many attack points get through in total for each card, this is
// calculated by simply doing;
// opponentsHits = yourCard[attack] - opponentsCard[defence]
// if the defence of the opposing card is greater than the attack value,
// no hits will be taken.
// at the end, all hits are added up and the winner is the one with
// the least total amount of hits, if it is a draw, the wager will be
// returned to the sender (minus the dev fee)
uint256[2] memory totalHits = [ uint256(0), uint256(0) ];
for (uint256 i = 0; i < 3; i++) {
// start with the opponent attack to you
totalHits[0] += (allFinalAttackFigures[1][i] > allFinalDefenceFigures[0][i] ? allFinalAttackFigures[1][i] - allFinalDefenceFigures[0][i] : 0);
// then your attack to the opponent
totalHits[1] += (allFinalAttackFigures[0][i] > allFinalDefenceFigures[1][i] ? allFinalAttackFigures[0][i] - allFinalDefenceFigures[1][i] : 0);
}
// before we process the outcome, we should log the event.
// order is important here as we should log a successful
// claim attempt then a transfer (if that's what happens)
// instead of the other way around
ClaimAttempt(
totalHits[0] < totalHits[1], // it was successful if we had less hits than the opponent
cardAddress,
msg.sender,
claimContender,
choices,
opponentCardChoices,
allFinalAttackFigures,
allFinalDefenceFigures
);
// handle the outcomes
uint256 tmpAmount;
if (totalHits[0] == totalHits[1]) { // we have a draw
// hand out the dev tax
tmpAmount = SafeMath.div(SafeMath.mul(msg.value, devTax), 100); // 2%
_balanceOf[dev] = SafeMath.add(_balanceOf[dev], tmpAmount);
// now we return the rest to the sender
_balanceOf[msg.sender] = SafeMath.add(_balanceOf[msg.sender], SafeMath.sub(msg.value, tmpAmount)); // 98%
} else if (totalHits[0] > totalHits[1]) { // we have more hits so we were unsuccessful
// hand out the dev tax
tmpAmount = SafeMath.div(SafeMath.mul(msg.value, devTax), 100); // 2%
_balanceOf[dev] = SafeMath.add(_balanceOf[dev], tmpAmount);
// now we give the rest to the claim contender
_balanceOf[claimContender] = SafeMath.add(_balanceOf[claimContender], SafeMath.sub(msg.value, tmpAmount)); // 98%
} else { // this means we have less hits than the opponent so we were successful in our claim!
// hand out the dev tax
tmpAmount = SafeMath.div(SafeMath.mul(msg.value, devTax), 100); // 2%
_balanceOf[dev] = SafeMath.add(_balanceOf[dev], tmpAmount);
// return half to the sender
_balanceOf[msg.sender] = SafeMath.add(_balanceOf[msg.sender], SafeMath.div(msg.value, 2)); // 50%
// and now the remainder goes to the claim contender
_balanceOf[claimContender] = SafeMath.add(_balanceOf[claimContender], SafeMath.sub(SafeMath.div(msg.value, 2), tmpAmount)); // 48%
// finally transfer the ownership of the card from the claim contender to the sender but
// first we need to make sure to cancel the wager
_ownersClaimPriceOf[cardAddress][claimContenderIndex] = 0;
transferCard(cardAddress, claimContender, msg.sender);
// now update our statistics
updateCardStatistics(cardAddress);
}
}
| function attemptToClaimCard(address cardAddress, address[3] choices) public payable {
// a lot of the functionality of attemptToClaimCard() is calculated in other methods as
// there is only a 16 local variable limit per method and we need a lot more than that
// see ownerCanClaimCard() below, this ensures we can actually claim the card we are after
// by running through various requirement checks
address claimContender;
uint256 claimContenderIndex;
(claimContender, claimContenderIndex) = ownerCanClaimCard(msg.sender, cardAddress, choices, msg.value);
address[3] memory opponentCardChoices = generateCardsFromClaimForOpponent(cardAddress, claimContender);
uint256[3][2] memory allFinalAttackFigures;
uint256[3][2] memory allFinalDefenceFigures;
(allFinalAttackFigures, allFinalDefenceFigures) = calculateAdjustedFiguresForBattle(choices, opponentCardChoices);
// after this point we have all of the modified attack and defence figures
// in the arrays above. the way the winner is determined is by counting
// how many attack points get through in total for each card, this is
// calculated by simply doing;
// opponentsHits = yourCard[attack] - opponentsCard[defence]
// if the defence of the opposing card is greater than the attack value,
// no hits will be taken.
// at the end, all hits are added up and the winner is the one with
// the least total amount of hits, if it is a draw, the wager will be
// returned to the sender (minus the dev fee)
uint256[2] memory totalHits = [ uint256(0), uint256(0) ];
for (uint256 i = 0; i < 3; i++) {
// start with the opponent attack to you
totalHits[0] += (allFinalAttackFigures[1][i] > allFinalDefenceFigures[0][i] ? allFinalAttackFigures[1][i] - allFinalDefenceFigures[0][i] : 0);
// then your attack to the opponent
totalHits[1] += (allFinalAttackFigures[0][i] > allFinalDefenceFigures[1][i] ? allFinalAttackFigures[0][i] - allFinalDefenceFigures[1][i] : 0);
}
// before we process the outcome, we should log the event.
// order is important here as we should log a successful
// claim attempt then a transfer (if that's what happens)
// instead of the other way around
ClaimAttempt(
totalHits[0] < totalHits[1], // it was successful if we had less hits than the opponent
cardAddress,
msg.sender,
claimContender,
choices,
opponentCardChoices,
allFinalAttackFigures,
allFinalDefenceFigures
);
// handle the outcomes
uint256 tmpAmount;
if (totalHits[0] == totalHits[1]) { // we have a draw
// hand out the dev tax
tmpAmount = SafeMath.div(SafeMath.mul(msg.value, devTax), 100); // 2%
_balanceOf[dev] = SafeMath.add(_balanceOf[dev], tmpAmount);
// now we return the rest to the sender
_balanceOf[msg.sender] = SafeMath.add(_balanceOf[msg.sender], SafeMath.sub(msg.value, tmpAmount)); // 98%
} else if (totalHits[0] > totalHits[1]) { // we have more hits so we were unsuccessful
// hand out the dev tax
tmpAmount = SafeMath.div(SafeMath.mul(msg.value, devTax), 100); // 2%
_balanceOf[dev] = SafeMath.add(_balanceOf[dev], tmpAmount);
// now we give the rest to the claim contender
_balanceOf[claimContender] = SafeMath.add(_balanceOf[claimContender], SafeMath.sub(msg.value, tmpAmount)); // 98%
} else { // this means we have less hits than the opponent so we were successful in our claim!
// hand out the dev tax
tmpAmount = SafeMath.div(SafeMath.mul(msg.value, devTax), 100); // 2%
_balanceOf[dev] = SafeMath.add(_balanceOf[dev], tmpAmount);
// return half to the sender
_balanceOf[msg.sender] = SafeMath.add(_balanceOf[msg.sender], SafeMath.div(msg.value, 2)); // 50%
// and now the remainder goes to the claim contender
_balanceOf[claimContender] = SafeMath.add(_balanceOf[claimContender], SafeMath.sub(SafeMath.div(msg.value, 2), tmpAmount)); // 48%
// finally transfer the ownership of the card from the claim contender to the sender but
// first we need to make sure to cancel the wager
_ownersClaimPriceOf[cardAddress][claimContenderIndex] = 0;
transferCard(cardAddress, claimContender, msg.sender);
// now update our statistics
updateCardStatistics(cardAddress);
}
}
| 50,783 |
226 | // copy the last item in the list into the now-unused slot,making sure to update its :managerForIndexes reference | uint32[] storage prevMfor = managerFor[prev];
uint256 last = prevMfor.length - 1;
uint32 moved = prevMfor[last];
prevMfor[i] = moved;
managerForIndexes[prev][moved] = i + 1;
| uint32[] storage prevMfor = managerFor[prev];
uint256 last = prevMfor.length - 1;
uint32 moved = prevMfor[last];
prevMfor[i] = moved;
managerForIndexes[prev][moved] = i + 1;
| 36,991 |
88 | // Duplicate token index check | for (uint j = i + 1; j < tokenIndices.length; j++) {
require(tokenIndices[i] != tokenIndices[j], "Duplicate token index");
}
| for (uint j = i + 1; j < tokenIndices.length; j++) {
require(tokenIndices[i] != tokenIndices[j], "Duplicate token index");
}
| 34,884 |
34 | // Standard ERC20 tokenImplemantation of the basic standart token. / | contract StandardToken is BasicToken, ERC20 {
mapping (address => mapping (address => uint)) allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint the amout of tokens to be transfered
*/
function transferFrom(address _from, address _to, uint _value) public {
uint256 _allowance = allowed[_from][msg.sender];
// Check is not needed because sub(_allowance, _value) will already revert() if this condition is not met
// if (_value > _allowance) revert();
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = _allowance.sub(_value);
emit Transfer(_from, _to, _value);
}
/**
* @dev Aprove the passed address to spend the specified amount of tokens on beahlf of msg.sender.
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint _value) public {
// To change the approve amount you first have to reduce the addresses`
// allowance to zero by calling `approve(_spender, 0)` if it is not
// already 0 to mitigate the race condition described here:
// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
if ((_value != 0) && (allowed[msg.sender][_spender] != 0)) revert("approve revert");
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
}
/**
* @dev Function to check the amount of tokens than an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint specifing the amount of tokens still avaible for the spender.
*/
function allowance(address _owner, address _spender) public view returns (uint remaining) {
return allowed[_owner][_spender];
}
}
| contract StandardToken is BasicToken, ERC20 {
mapping (address => mapping (address => uint)) allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint the amout of tokens to be transfered
*/
function transferFrom(address _from, address _to, uint _value) public {
uint256 _allowance = allowed[_from][msg.sender];
// Check is not needed because sub(_allowance, _value) will already revert() if this condition is not met
// if (_value > _allowance) revert();
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = _allowance.sub(_value);
emit Transfer(_from, _to, _value);
}
/**
* @dev Aprove the passed address to spend the specified amount of tokens on beahlf of msg.sender.
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint _value) public {
// To change the approve amount you first have to reduce the addresses`
// allowance to zero by calling `approve(_spender, 0)` if it is not
// already 0 to mitigate the race condition described here:
// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
if ((_value != 0) && (allowed[msg.sender][_spender] != 0)) revert("approve revert");
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
}
/**
* @dev Function to check the amount of tokens than an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint specifing the amount of tokens still avaible for the spender.
*/
function allowance(address _owner, address _spender) public view returns (uint remaining) {
return allowed[_owner][_spender];
}
}
| 15,968 |
11 | // ERC20 contract/ https:github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md | contract ERC20 {
uint public totalSupply;
function balanceOf(address who) public constant returns (uint);
function transfer(address to, uint value) public returns (bool);
event Transfer(address indexed from, address indexed to, uint value);
function allowance(address owner, address spender) public constant returns (uint);
function transferFrom(address from, address to, uint value) public returns (bool);
function approve(address spender, uint value) public returns (bool);
event Approval(address indexed owner, address indexed spender, uint value);
}
| contract ERC20 {
uint public totalSupply;
function balanceOf(address who) public constant returns (uint);
function transfer(address to, uint value) public returns (bool);
event Transfer(address indexed from, address indexed to, uint value);
function allowance(address owner, address spender) public constant returns (uint);
function transferFrom(address from, address to, uint value) public returns (bool);
function approve(address spender, uint value) public returns (bool);
event Approval(address indexed owner, address indexed spender, uint value);
}
| 36,943 |
41 | // Deposit `assetAmount` amount of `asset` into strategies according to each strategy's `tvlBps`. | function _depositIntoStrategies(uint256 assetAmount) internal {
// All non-zero strategies are active
for (uint256 i = 0; i < MAX_STRATEGIES; i = uncheckedInc(i)) {
Strategy strategy = withdrawalQueue[i];
if (address(strategy) == address(0)) {
break;
}
_depositIntoStrategy(strategy, (assetAmount * strategies[strategy].tvlBps) / MAX_BPS);
}
}
| function _depositIntoStrategies(uint256 assetAmount) internal {
// All non-zero strategies are active
for (uint256 i = 0; i < MAX_STRATEGIES; i = uncheckedInc(i)) {
Strategy strategy = withdrawalQueue[i];
if (address(strategy) == address(0)) {
break;
}
_depositIntoStrategy(strategy, (assetAmount * strategies[strategy].tvlBps) / MAX_BPS);
}
}
| 1,388 |
2 | // Recursive proof input data (individual commitments are constructed onchain)/ TODO: The verifier integration is not finished yet, change the structure for compatibility later | struct ProofInput {
uint256[] recurisiveAggregationInput;
uint256[] serializedProof;
}
| struct ProofInput {
uint256[] recurisiveAggregationInput;
uint256[] serializedProof;
}
| 5,177 |
113 | // ========== OWNER ============= // Add a new consumer. Can only be called by the owner / | function add(
uint256 _allocPoint,
address _consumer,
uint256 _startBlock
| function add(
uint256 _allocPoint,
address _consumer,
uint256 _startBlock
| 64,370 |
6 | // two256modP == 2^256 mod FIELD_MODULUS; this is used in hashToBase to obtain a more uniform hash value. | uint256 constant two256modP = 6350874878119819312338956282401532409788428879151445726012394534686998597021;
| uint256 constant two256modP = 6350874878119819312338956282401532409788428879151445726012394534686998597021;
| 5,646 |
18 | // 34710 is the value that solidity is currently emitting It includes callGas (700) + callVeryLow (3, to pay for SUB) + callValueTransferGas (9000) + callNewAccountGas (25000, in case the destination address does not exist and needs creating) | sub(gas(), 34710),
destination,
0, // transfer value in wei
dataAddress,
mload(data), // Size of the input, in bytes. Stored in position 0 of the array.
outputAddress,
0 // Output is ignored, therefore the output size is zero
)
| sub(gas(), 34710),
destination,
0, // transfer value in wei
dataAddress,
mload(data), // Size of the input, in bytes. Stored in position 0 of the array.
outputAddress,
0 // Output is ignored, therefore the output size is zero
)
| 29,708 |
232 | // Mint to the user. | _mint(to, base * count);
uint256 totalFee = mintFee * count;
_chargeAndDistributeFees(totalFee);
emit Minted(tokenIds, amounts, to);
return count;
| _mint(to, base * count);
uint256 totalFee = mintFee * count;
_chargeAndDistributeFees(totalFee);
emit Minted(tokenIds, amounts, to);
return count;
| 83,487 |
282 | // Miner can waive fees for this order. If waiveFeePercentage > 0 this is a simple reduction in fees. | if (feeCtx.waiveFeePercentage > 0) {
minerFee = minerFee.mul(
feeCtx.ctx.feePercentageBase - uint(feeCtx.waiveFeePercentage)) /
feeCtx.ctx.feePercentageBase;
} else if (feeCtx.waiveFeePercentage < 0) {
| if (feeCtx.waiveFeePercentage > 0) {
minerFee = minerFee.mul(
feeCtx.ctx.feePercentageBase - uint(feeCtx.waiveFeePercentage)) /
feeCtx.ctx.feePercentageBase;
} else if (feeCtx.waiveFeePercentage < 0) {
| 42,426 |
49 | // Trade Dai for Ether using reserves. | totalDaiSold = _TRADEDAIFORETHER930(
daiAmountFromReserves, quotedEtherAmount, deadline, true
);
| totalDaiSold = _TRADEDAIFORETHER930(
daiAmountFromReserves, quotedEtherAmount, deadline, true
);
| 7,469 |
332 | // Stores the id return by the oraclize query. Maintains record of all the Ids return by oraclize query. myid Id return by the oraclize query. / | function addInAllApiCall(bytes32 myid) external onlyInternal {
allAPIcall.push(myid);
}
| function addInAllApiCall(bytes32 myid) external onlyInternal {
allAPIcall.push(myid);
}
| 28,981 |
90 | // Values for random | uint private nonce;
uint private seed1;
uint private seed2;
| uint private nonce;
uint private seed1;
uint private seed2;
| 12,175 |
45 | // Constant overhead | RELAY_CONSTANT_OVERHEAD +
| RELAY_CONSTANT_OVERHEAD +
| 12,345 |
27 | // Amended keys, old address => new address. New address is allowed to claim for old address. | mapping (address => address) public amended;
| mapping (address => address) public amended;
| 34,477 |
374 | // Adds a transaction to the queue. _target Target contract to send the transaction to. _gasLimit Gas limit for the given transaction. _data Transaction data. / | function enqueue(
| function enqueue(
| 80,656 |
30 | // Transfer event as defined in current draft of ERC721. Emitted every time a kitten/ownership is assigned, including births. | event Transfer(address from, address to, uint256 tokenId);
event Vote(uint16 candidate, uint256 voteCount, uint16 currentGenerator, uint256 currentGeneratorVoteCount);
event NewRecipient(address recipient, uint256 position);
event NewGenerator(uint256 position);
| event Transfer(address from, address to, uint256 tokenId);
event Vote(uint16 candidate, uint256 voteCount, uint16 currentGenerator, uint256 currentGeneratorVoteCount);
event NewRecipient(address recipient, uint256 position);
event NewGenerator(uint256 position);
| 6,720 |
47 | // marketId => Market | mapping(uint => Market) markets;
| mapping(uint => Market) markets;
| 22,128 |
3 | // A Component gets into Broken state if one of the components has been removed without being replaced if a component gets into broken state must be changed with another one that you are the owner of | Broken, // 3
| Broken, // 3
| 48,179 |
105 | // Invert denominator mod 2256. Now that denominator is an odd number, it has an inverse modulo 2256 such that denominatorinv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for four bits. That is, denominatorinv = 1 mod 2^4 If denominator is zero the inverse starts with 23denominator^2 =denominator^(-1) mod 2^43denominator^3 = 1mod 2^4 | let inv := mul(3, mul(denominator, denominator))
| let inv := mul(3, mul(denominator, denominator))
| 653 |
1 | // To store the Data Hash => Singature Hash | mapping(bytes32 => bytes32) public signatures;
| mapping(bytes32 => bytes32) public signatures;
| 14,174 |
36 | // Total resources frozen for an address/_tokenOwner The address to look up/ return The frozen balance of the address | function frozenTokens(address _tokenOwner)
public
constant
returns(uint balance)
| function frozenTokens(address _tokenOwner)
public
constant
returns(uint balance)
| 41,768 |
16 | // SafeMath contract - math operations with safety checks /<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="086c6d7e487b65697a7c6b67667c7a696b7c6d6965266b6765">[email&160;protected]</a> | contract SafeMath {
function safeMul(uint a, uint b) internal returns (uint) {
uint c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function safeDiv(uint a, uint b) internal returns (uint) {
assert(b > 0);
uint c = a / b;
assert(a == b * c + a % b);
return c;
}
function safeSub(uint a, uint b) internal returns (uint) {
assert(b <= a);
return a - b;
}
function safeAdd(uint a, uint b) internal returns (uint) {
uint c = a + b;
assert(c>=a && c>=b);
return c;
}
function max64(uint64 a, uint64 b) internal constant returns (uint64) {
return a >= b ? a : b;
}
function min64(uint64 a, uint64 b) internal constant returns (uint64) {
return a < b ? a : b;
}
function max256(uint256 a, uint256 b) internal constant returns (uint256) {
return a >= b ? a : b;
}
function min256(uint256 a, uint256 b) internal constant returns (uint256) {
return a < b ? a : b;
}
function assert(bool assertion) internal {
require(assertion);
}
}
| contract SafeMath {
function safeMul(uint a, uint b) internal returns (uint) {
uint c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function safeDiv(uint a, uint b) internal returns (uint) {
assert(b > 0);
uint c = a / b;
assert(a == b * c + a % b);
return c;
}
function safeSub(uint a, uint b) internal returns (uint) {
assert(b <= a);
return a - b;
}
function safeAdd(uint a, uint b) internal returns (uint) {
uint c = a + b;
assert(c>=a && c>=b);
return c;
}
function max64(uint64 a, uint64 b) internal constant returns (uint64) {
return a >= b ? a : b;
}
function min64(uint64 a, uint64 b) internal constant returns (uint64) {
return a < b ? a : b;
}
function max256(uint256 a, uint256 b) internal constant returns (uint256) {
return a >= b ? a : b;
}
function min256(uint256 a, uint256 b) internal constant returns (uint256) {
return a < b ? a : b;
}
function assert(bool assertion) internal {
require(assertion);
}
}
| 6,961 |
5 | // Mapping of a cycle members. key is the cycle id | mapping(uint256 => RecordIndex[]) private CycleMembersIndexer;
| mapping(uint256 => RecordIndex[]) private CycleMembersIndexer;
| 23,531 |
1 | // Upgrade Beacon address is immutable (therefore not kept in contract storage) | address private immutable upgradeBeacon;
| address private immutable upgradeBeacon;
| 19,400 |
61 | // Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. Tokens start existing when they are minted (`_mint`), / | function _exists(uint256 tokenId) internal view returns (bool) {
return tokenId < currentIndex;
}
| function _exists(uint256 tokenId) internal view returns (bool) {
return tokenId < currentIndex;
}
| 2,132 |
63 | // NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the`0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103` / | function admin() external ifAdmin returns (address) {
return _admin();
}
| function admin() external ifAdmin returns (address) {
return _admin();
}
| 1,582 |
90 | // deploy fractionalized NFT vault | uint256 vaultNumber =
IERC721VaultFactory(tokenVaultFactory).mint(
name,
symbol,
nftContract,
tokenId,
valueToTokens(_totalSpent),
_totalSpent,
0
);
| uint256 vaultNumber =
IERC721VaultFactory(tokenVaultFactory).mint(
name,
symbol,
nftContract,
tokenId,
valueToTokens(_totalSpent),
_totalSpent,
0
);
| 23,199 |
37 | // if the token is not a reserve token, allow withdrawal otherwise verify that the converter is inactive or that the owner is the upgrader contract | require(!reserves[_token].isSet || !isActive() || owner == converterUpgrader, "ERR_ACCESS_DENIED");
super.withdrawTokens(_token, _to, _amount);
| require(!reserves[_token].isSet || !isActive() || owner == converterUpgrader, "ERR_ACCESS_DENIED");
super.withdrawTokens(_token, _to, _amount);
| 17,676 |
229 | // Bonus muliplier for early DogeMatic makers. | uint256 public constant BONUS_MULTIPLIER = 1;
| uint256 public constant BONUS_MULTIPLIER = 1;
| 1,397 |
107 | // Function to get immediate payable debenture | function getImmediateDebenture(address _accountAddress) internal isApproved view returns(int256) {
// Find M-Bill debenture next in line to be cleared
uint256 pendingMDebentures = outstandingMDebentures(_accountAddress);
// Find total M-Bill debentures
uint256 totalMDebentures = accounts[accountIndexes[_accountAddress]].mDebentureIndexes.length;
if(pendingMDebentures == 0 || totalMDebentures == 0) {
return int256(-1);
} else {
uint256 MDebentureIndex = accounts[accountIndexes[_accountAddress]].mDebentureIndexes[totalMDebentures.sub(pendingMDebentures)];
return int256(MDebentureIndex);
}
}
| function getImmediateDebenture(address _accountAddress) internal isApproved view returns(int256) {
// Find M-Bill debenture next in line to be cleared
uint256 pendingMDebentures = outstandingMDebentures(_accountAddress);
// Find total M-Bill debentures
uint256 totalMDebentures = accounts[accountIndexes[_accountAddress]].mDebentureIndexes.length;
if(pendingMDebentures == 0 || totalMDebentures == 0) {
return int256(-1);
} else {
uint256 MDebentureIndex = accounts[accountIndexes[_accountAddress]].mDebentureIndexes[totalMDebentures.sub(pendingMDebentures)];
return int256(MDebentureIndex);
}
}
| 52,822 |
18 | // todo: give voter possibility to withdraw money (safer) | lonelyBider.transfer(bidsum);
return;
| lonelyBider.transfer(bidsum);
return;
| 4,118 |
73 | // Internal check to see if allocator is migrating. / | function _isMigrating(AllocatorStatus inputStatus) internal pure {
if (inputStatus != AllocatorStatus.MIGRATING) revert BaseAllocator_NotMigrating();
}
| function _isMigrating(AllocatorStatus inputStatus) internal pure {
if (inputStatus != AllocatorStatus.MIGRATING) revert BaseAllocator_NotMigrating();
}
| 46,891 |
117 | // Generation | metadata = strConcat(metadata, ' {\n');
metadata = strConcat(metadata, ' "display_type": "number",\n');
metadata = strConcat(metadata, ' "trait_type": "generation",\n');
metadata = strConcat(metadata, ' "value": ');
metadata = strConcat(metadata, uintToStr(uint8(generation) + 1));
metadata = strConcat(metadata, '\n },\n');
| metadata = strConcat(metadata, ' {\n');
metadata = strConcat(metadata, ' "display_type": "number",\n');
metadata = strConcat(metadata, ' "trait_type": "generation",\n');
metadata = strConcat(metadata, ' "value": ');
metadata = strConcat(metadata, uintToStr(uint8(generation) + 1));
metadata = strConcat(metadata, '\n },\n');
| 30,389 |
5 | // Allows the current owner to set the pendingOwner address.newOwner The address to transfer ownership to./ | function transferOwnership(address newOwner) public onlyOwner {
pendingOwner_ = newOwner;
}
| function transferOwnership(address newOwner) public onlyOwner {
pendingOwner_ = newOwner;
}
| 37,189 |
187 | // Returns the total supply of votes available at the end of a past block (`blockNumber`). NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes.Votes that have not been delegated are still part of total supply, even though they would not participate in avote. / | function getPastTotalSupply(uint256 blockNumber) external view returns (uint256);
| function getPastTotalSupply(uint256 blockNumber) external view returns (uint256);
| 664 |
60 | // videoID => publisher | mapping (bytes12 => address) public videos;
event Published(bytes12 videoID);
function VideoPublisher(
DSToken viewToken_,
uint priceView_,
| mapping (bytes12 => address) public videos;
event Published(bytes12 videoID);
function VideoPublisher(
DSToken viewToken_,
uint priceView_,
| 10,767 |
6 | // given some amount of an asset and pair reserves, returns an equivalent amount of the other asset | function quote(
uint amountA,
uint reserveA,
uint reserveB
| function quote(
uint amountA,
uint reserveA,
uint reserveB
| 15,950 |
2 | // assert(_b > 0);Solidity automatically throws when dividing by 0 uint256 c = _a / _b; assert(_a == _bc + _a % _b);There is no case in which this doesn't hold | return _a / _b;
| return _a / _b;
| 379 |
21 | // update | validators[newValidatorSetId] = newValidators;
activeValidatorSetId = newValidatorSetId;
| validators[newValidatorSetId] = newValidators;
activeValidatorSetId = newValidatorSetId;
| 10,905 |
197 | // Record refund in event logs | emit BetRefunded(betId, bet.gambler, amount);
| emit BetRefunded(betId, bet.gambler, amount);
| 18,108 |
135 | // Has the auction been closed? | bool closed;
| bool closed;
| 1,347 |
9 | // ADMIN FUNCTIONSsets new `owner` state variable. Granting new owner control to admin functions.address.New address to be set. | function setNewOwner(address _newOwner) public onlyOwner {
owner = _newOwner;
}
| function setNewOwner(address _newOwner) public onlyOwner {
owner = _newOwner;
}
| 38,542 |
80 | // Utility function to check if a value is inside an array | function _isInArray(uint256 _value, uint256[] memory _array)
internal
pure
returns (bool)
| function _isInArray(uint256 _value, uint256[] memory _array)
internal
pure
returns (bool)
| 2,569 |
4 | // use the return value (true or false) to test the contract | return true;
| return true;
| 27,823 |
42 | // freezing chains | mapping (bytes32 => uint64) internal chains;
| mapping (bytes32 => uint64) internal chains;
| 20,216 |
245 | // this must be called before the user's balance is updated so the rewards contract can calculate the amount owed correctly | if (address(ds.rewards) != address(0)) {
ds.rewards.registerUserAction(msg.sender);
}
| if (address(ds.rewards) != address(0)) {
ds.rewards.registerUserAction(msg.sender);
}
| 38,545 |
32 | // Pay LUSD_USDC_POOL for the swap by passing it as a recipient to the next swap (WETH -> USDC) | IUniswapV3PoolActions(USDC_ETH_POOL).swap(
LUSD_USDC_POOL, // recipient
false, // zeroForOne
-_amount1Delta, // amount of USDC to pay to LUSD_USDC_POOL for the swap
SQRT_PRICE_LIMIT_X96,
""
);
| IUniswapV3PoolActions(USDC_ETH_POOL).swap(
LUSD_USDC_POOL, // recipient
false, // zeroForOne
-_amount1Delta, // amount of USDC to pay to LUSD_USDC_POOL for the swap
SQRT_PRICE_LIMIT_X96,
""
);
| 14,013 |
193 | // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reserve factor change failed. | return fail(Error(error), FailureInfo.SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED);
| return fail(Error(error), FailureInfo.SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED);
| 9,297 |
130 | // Calls the function with selector 0x01ffc9a7 (ERC165) and suppresses throw account The address of the contract to query for support of an interface interfaceId The interface identifier, as specified in ERC-165return success true if the STATICCALL succeeded, false otherwisereturn result true if the STATICCALL succeeded and the contract at accountindicates support of the interface with identifier interfaceId, false otherwise / | function _callERC165SupportsInterface(address account, bytes4 interfaceId)
private
view
returns (bool, bool)
| function _callERC165SupportsInterface(address account, bytes4 interfaceId)
private
view
returns (bool, bool)
| 31,141 |
6 | // converting to bech32/base32 w/ no checksum | library Base32Lib {
// see https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki#bech32 for alphabet
bytes constant ALPHABET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
// modified toBase58 impl from https://github.com/MrChico/verifyIPFS/blob/b4bfb3df52e7e012a4ef668c6b3dbc038f881fd9/contracts/verifyIPFS.sol
// MIT Licensed - https://github.com/MrChico/verifyIPFS/blob/b4bfb3df52e7e012a4ef668c6b3dbc038f881fd9/LICENSE
function toBase32(bytes source) internal pure returns (bytes) {
if (source.length == 0) return new bytes(0);
uint8[] memory digits = new uint8[](40); //TODO: figure out exactly how much is needed
digits[0] = 0;
uint8 digitlength = 1;
for (uint8 i = 0; i < source.length; ++i) {
uint carry = uint8(source[i]);
for (uint8 j = 0; j < digitlength; ++j) {
carry += uint(digits[j]) * 256;
digits[j] = uint8(carry % 32);
carry = carry / 32;
}
while (carry > 0) {
digits[digitlength] = uint8(carry % 32);
digitlength++;
carry = carry / 32;
}
}
//return digits;
return toAlphabet(reverse(truncate(digits, digitlength)));
}
function truncate(uint8[] array, uint8 length) pure internal returns (uint8[]) {
uint8[] memory output = new uint8[](length);
for (uint8 i = 0; i<length; i++) {
output[i] = array[i];
}
return output;
}
function reverse(uint8[] input) pure internal returns (uint8[]) {
uint8[] memory output = new uint8[](input.length);
for (uint8 i = 0; i<input.length; i++) {
output[i] = input[input.length-1-i];
}
return output;
}
function toAlphabet(uint8[] indices) pure internal returns (bytes) {
bytes memory output = new bytes(indices.length);
for (uint8 i = 0; i<indices.length; i++) {
output[i] = ALPHABET[indices[i]];
}
return output;
}
}
| library Base32Lib {
// see https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki#bech32 for alphabet
bytes constant ALPHABET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
// modified toBase58 impl from https://github.com/MrChico/verifyIPFS/blob/b4bfb3df52e7e012a4ef668c6b3dbc038f881fd9/contracts/verifyIPFS.sol
// MIT Licensed - https://github.com/MrChico/verifyIPFS/blob/b4bfb3df52e7e012a4ef668c6b3dbc038f881fd9/LICENSE
function toBase32(bytes source) internal pure returns (bytes) {
if (source.length == 0) return new bytes(0);
uint8[] memory digits = new uint8[](40); //TODO: figure out exactly how much is needed
digits[0] = 0;
uint8 digitlength = 1;
for (uint8 i = 0; i < source.length; ++i) {
uint carry = uint8(source[i]);
for (uint8 j = 0; j < digitlength; ++j) {
carry += uint(digits[j]) * 256;
digits[j] = uint8(carry % 32);
carry = carry / 32;
}
while (carry > 0) {
digits[digitlength] = uint8(carry % 32);
digitlength++;
carry = carry / 32;
}
}
//return digits;
return toAlphabet(reverse(truncate(digits, digitlength)));
}
function truncate(uint8[] array, uint8 length) pure internal returns (uint8[]) {
uint8[] memory output = new uint8[](length);
for (uint8 i = 0; i<length; i++) {
output[i] = array[i];
}
return output;
}
function reverse(uint8[] input) pure internal returns (uint8[]) {
uint8[] memory output = new uint8[](input.length);
for (uint8 i = 0; i<input.length; i++) {
output[i] = input[input.length-1-i];
}
return output;
}
function toAlphabet(uint8[] indices) pure internal returns (bytes) {
bytes memory output = new bytes(indices.length);
for (uint8 i = 0; i<indices.length; i++) {
output[i] = ALPHABET[indices[i]];
}
return output;
}
}
| 28,784 |
10 | // ============================== ERC20 | event Transfer(
address indexed from,
address indexed to,
uint256 tokens
);
| event Transfer(
address indexed from,
address indexed to,
uint256 tokens
);
| 60 |
95 | // allocate gas refund | if (depositParams.token0 == tokenShares.weth && depositParams.wrap) {
value = value.sub(depositParams.amount0, 'OS_NOT_ENOUGH_FUNDS');
} else if (depositParams.token1 == tokenShares.weth && depositParams.wrap) {
| if (depositParams.token0 == tokenShares.weth && depositParams.wrap) {
value = value.sub(depositParams.amount0, 'OS_NOT_ENOUGH_FUNDS');
} else if (depositParams.token1 == tokenShares.weth && depositParams.wrap) {
| 37,975 |
2 | // Returns the address where a contract will be stored if deployed via {createReserveNFT}. Any change in the `bytecodeHash` or `salt` will result in a new destination address./ | function computeAddress(string memory _name, string memory _symbol, string memory _brand) public view returns (address) {
bytes memory bytecode = abi.encodePacked(type(ShopXReserveNFT).creationCode, abi.encode(
_name,
_symbol,
_brand
));
bytes32 bytecodeHash = keccak256(abi.encodePacked(bytecode));
bytes32 _data = keccak256(abi.encodePacked(bytes1(0xff), address(this), bytes32(0), bytecodeHash));
return address(uint160(uint256(_data)));
}
| function computeAddress(string memory _name, string memory _symbol, string memory _brand) public view returns (address) {
bytes memory bytecode = abi.encodePacked(type(ShopXReserveNFT).creationCode, abi.encode(
_name,
_symbol,
_brand
));
bytes32 bytecodeHash = keccak256(abi.encodePacked(bytecode));
bytes32 _data = keccak256(abi.encodePacked(bytes1(0xff), address(this), bytes32(0), bytecodeHash));
return address(uint160(uint256(_data)));
}
| 17,243 |
4 | // move entry id from the end of the array if entries[id].index is not the last index for the array entries order can change in ids | if(e.index < ids.length - 1) {
ids[e.index] = ids[ids.length - 1];
entries[ids[ids.length - 1]].index = e.index;
}
| if(e.index < ids.length - 1) {
ids[e.index] = ids[ids.length - 1];
entries[ids[ids.length - 1]].index = e.index;
}
| 40,277 |
104 | // Claim rewardToken and convert rewardToken into collateral token.Calculate interest fee on earning from rewardToken and transfer balance minusfee to pool. Transferring collateral to pool will increase pool share price. / | function _claimComp() internal {
address[] memory markets = new address[](1);
markets[0] = address(cToken);
comptroller.claimComp(address(this), markets);
uint256 amt = IERC20(rewardToken).balanceOf(address(this));
if (amt != 0) {
IUniswapV2Router02 uniswapRouter = IUniswapV2Router02(controller.uniswapRouter());
address[] memory path = _getPath(rewardToken, address(collateralToken));
uint256 amountOut = uniswapRouter.getAmountsOut(amt, path)[path.length - 1];
if (amountOut != 0) {
IERC20(rewardToken).safeApprove(address(uniswapRouter), 0);
IERC20(rewardToken).safeApprove(address(uniswapRouter), amt);
uniswapRouter.swapExactTokensForTokens(amt, 1, path, address(this), now + 30);
uint256 _collateralEarned = collateralToken.balanceOf(address(this));
uint256 _fee = _collateralEarned.mul(controller.interestFee(pool)).div(1e18);
collateralToken.safeTransfer(pool, _collateralEarned.sub(_fee));
}
}
}
| function _claimComp() internal {
address[] memory markets = new address[](1);
markets[0] = address(cToken);
comptroller.claimComp(address(this), markets);
uint256 amt = IERC20(rewardToken).balanceOf(address(this));
if (amt != 0) {
IUniswapV2Router02 uniswapRouter = IUniswapV2Router02(controller.uniswapRouter());
address[] memory path = _getPath(rewardToken, address(collateralToken));
uint256 amountOut = uniswapRouter.getAmountsOut(amt, path)[path.length - 1];
if (amountOut != 0) {
IERC20(rewardToken).safeApprove(address(uniswapRouter), 0);
IERC20(rewardToken).safeApprove(address(uniswapRouter), amt);
uniswapRouter.swapExactTokensForTokens(amt, 1, path, address(this), now + 30);
uint256 _collateralEarned = collateralToken.balanceOf(address(this));
uint256 _fee = _collateralEarned.mul(controller.interestFee(pool)).div(1e18);
collateralToken.safeTransfer(pool, _collateralEarned.sub(_fee));
}
}
}
| 87,983 |
663 | // Returns the exchange rate between an underlying currency and asset for trading/ and free collateral. Mapping is from currency id to rate storage object. | function getAssetRateStorage() internal pure
returns (mapping(uint256 => AssetRateStorage) storage store)
| function getAssetRateStorage() internal pure
returns (mapping(uint256 => AssetRateStorage) storage store)
| 6,184 |
122 | // Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. Tokens start existing when they are minted (`_mint`),and stop existing when they are burned (`_burn`). / | function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
| function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
| 210 |
8 | // log event so UI can identify streams created by this contract and enable to search for streams by sender or recipient | emit CreateSealedStream(streamId, msg.sender, recipient, deposit, tokenAddress, startTime, stopTime);
| emit CreateSealedStream(streamId, msg.sender, recipient, deposit, tokenAddress, startTime, stopTime);
| 44,990 |
41 | // Lookup the dials _id for which we want the dialsreturn dial values of _id. / | function tokenDials(uint _id) external view returns (int256[] memory) {
return idToDials[_id];
}
| function tokenDials(uint _id) external view returns (int256[] memory) {
return idToDials[_id];
}
| 13,300 |
54 | // Issues `_value` new tokens to `_recipient`_recipient The address to which the tokens will be issued _value The amount of new tokens to issuereturn Whether the approval was successful or not / | function issue(address _recipient, uint256 _value) onlyOwner returns (bool success) {
// Create tokens
balances[_recipient] += _value;
totalSupply += _value;
balancesPerIcoPeriod[_recipient][getCurrentIcoNumber()] = balances[_recipient];
return true;
}
| function issue(address _recipient, uint256 _value) onlyOwner returns (bool success) {
// Create tokens
balances[_recipient] += _value;
totalSupply += _value;
balancesPerIcoPeriod[_recipient][getCurrentIcoNumber()] = balances[_recipient];
return true;
}
| 19,083 |
145 | // Goals: 1. if the _tokensToRedeem being claimed does not drain the vault to below 160% 2. pull out the amount of ether the senders' tokens entitle them to and send it to them |
(uint protocolFee,
uint automationFee,
uint collateralToFree,
uint collateralToReturn) = calculateRedemptionValue(_tokensToRedeem);
bytes memory freeETHProxyCall = abi.encodeWithSignature(
"freeETH(address,address,uint256,uint256)",
makerManager,
ethGemJoin,
|
(uint protocolFee,
uint automationFee,
uint collateralToFree,
uint collateralToReturn) = calculateRedemptionValue(_tokensToRedeem);
bytes memory freeETHProxyCall = abi.encodeWithSignature(
"freeETH(address,address,uint256,uint256)",
makerManager,
ethGemJoin,
| 17,780 |
9 | // sets the policybookFacade mpls values/_facadeAddress address of the policybook facade/_newRebalancingThreshold uint256 value of the reinsurance leverage mpl | function setPolicyBookFacadeRebalancingThreshold(
address _facadeAddress,
uint256 _newRebalancingThreshold
) external;
| function setPolicyBookFacadeRebalancingThreshold(
address _facadeAddress,
uint256 _newRebalancingThreshold
) external;
| 25,509 |
145 | // Deposit LP tokens to Chef for Token allocation. Also used to claim the users pending Token tokens (_amount = 0) | function deposit(uint256 _pid, uint256 _amount) external {
require(!Address.isContract(address(msg.sender)), "Please use your individual account.");
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accTokenPerLPShare).div(1e18).sub(user.rewardDebt);
safeTokenTransfer(msg.sender, pending);
}
pool.lpTokenContract.safeTransferFrom(address(msg.sender), address(this), _amount);
user.amount = user.amount.add(_amount);
user.rewardDebt = user.amount.mul(pool.accTokenPerLPShare).div(1e18);
emit Deposit(msg.sender, _pid, _amount);
}
| function deposit(uint256 _pid, uint256 _amount) external {
require(!Address.isContract(address(msg.sender)), "Please use your individual account.");
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accTokenPerLPShare).div(1e18).sub(user.rewardDebt);
safeTokenTransfer(msg.sender, pending);
}
pool.lpTokenContract.safeTransferFrom(address(msg.sender), address(this), _amount);
user.amount = user.amount.add(_amount);
user.rewardDebt = user.amount.mul(pool.accTokenPerLPShare).div(1e18);
emit Deposit(msg.sender, _pid, _amount);
}
| 20,896 |
261 | // Struct representing a price request. | struct Request {
address proposer; // Address of the proposer.
address disputer; // Address of the disputer.
IERC20 currency; // ERC20 token used to pay rewards and fees.
bool settled; // True if the request is settled.
bool refundOnDispute; // True if the requester should be refunded their reward on dispute.
int256 proposedPrice; // Price that the proposer submitted.
int256 resolvedPrice; // Price resolved once the request is settled.
uint256 expirationTime; // Time at which the request auto-settles without a dispute.
uint256 reward; // Amount of the currency to pay to the proposer on settlement.
uint256 finalFee; // Final fee to pay to the Store upon request to the DVM.
uint256 bond; // Bond that the proposer and disputer must pay on top of the final fee.
uint256 customLiveness; // Custom liveness value set by the requester.
}
| struct Request {
address proposer; // Address of the proposer.
address disputer; // Address of the disputer.
IERC20 currency; // ERC20 token used to pay rewards and fees.
bool settled; // True if the request is settled.
bool refundOnDispute; // True if the requester should be refunded their reward on dispute.
int256 proposedPrice; // Price that the proposer submitted.
int256 resolvedPrice; // Price resolved once the request is settled.
uint256 expirationTime; // Time at which the request auto-settles without a dispute.
uint256 reward; // Amount of the currency to pay to the proposer on settlement.
uint256 finalFee; // Final fee to pay to the Store upon request to the DVM.
uint256 bond; // Bond that the proposer and disputer must pay on top of the final fee.
uint256 customLiveness; // Custom liveness value set by the requester.
}
| 29,284 |
110 | // investor contribute eth to contract | * Emits a {Contribution} event.
* msg.value is amount to contribute
*/
function contributeETH() external whenNotPaused nonReentrant payable {
require(WETH == address(contributionToken), "invalid token");
uint256 cAmount = contributeInternal(msg.value);
IWETH(WETH).deposit{value: cAmount}();
if (msg.value > cAmount){
TransferHelper.safeTransferETH(msg.sender, msg.value.sub(cAmount));
}
emit Contribution(msg.sender, cAmount);
}
| * Emits a {Contribution} event.
* msg.value is amount to contribute
*/
function contributeETH() external whenNotPaused nonReentrant payable {
require(WETH == address(contributionToken), "invalid token");
uint256 cAmount = contributeInternal(msg.value);
IWETH(WETH).deposit{value: cAmount}();
if (msg.value > cAmount){
TransferHelper.safeTransferETH(msg.sender, msg.value.sub(cAmount));
}
emit Contribution(msg.sender, cAmount);
}
| 52,352 |
10 | // At any given moment, returns the uid for the active claim condition. | function getIndexOfActiveCondition() public view returns (uint256) {
uint256 totalConditionCount = claimConditions.totalConditionCount;
require(totalConditionCount > 0, "no public mint condition.");
for (uint256 i = totalConditionCount; i > 0; i -= 1) {
if (block.timestamp >= claimConditions.claimConditionAtIndex[i - 1].startTimestamp) {
return i - 1;
}
}
revert("no active mint condition.");
}
| function getIndexOfActiveCondition() public view returns (uint256) {
uint256 totalConditionCount = claimConditions.totalConditionCount;
require(totalConditionCount > 0, "no public mint condition.");
for (uint256 i = totalConditionCount; i > 0; i -= 1) {
if (block.timestamp >= claimConditions.claimConditionAtIndex[i - 1].startTimestamp) {
return i - 1;
}
}
revert("no active mint condition.");
}
| 49,459 |
3 | // Returns the multiplication of two unsigned integers, reverting onoverflow. / | function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
| function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
| 28,223 |
3 | // Returns all escrowIds which an account has/had claims in account address / | function getEscrowsByUser(address account)
external
view
returns (bytes32[] memory)
| function getEscrowsByUser(address account)
external
view
returns (bytes32[] memory)
| 10,262 |
73 | // all new liquidity goes to the dead address | liquidityAddress = payable(address(0xdead));
restoreAllFee();
| liquidityAddress = payable(address(0xdead));
restoreAllFee();
| 13,683 |
206 | // update the amount of tokens to be minted and collaterals to be claimed | tokensToBeMinted = tokensToBeMinted.sub(deprecatedBuyReturn).add(batch.totalBuyReturn);
collateralsToBeClaimed[_collateral] = collateralsToBeClaimed[_collateral].sub(deprecatedSellReturn).add(batch.totalSellReturn);
| tokensToBeMinted = tokensToBeMinted.sub(deprecatedBuyReturn).add(batch.totalBuyReturn);
collateralsToBeClaimed[_collateral] = collateralsToBeClaimed[_collateral].sub(deprecatedSellReturn).add(batch.totalSellReturn);
| 20,732 |
108 | // reset offer if the offer exits | cardsForSale[_tokenId] = Offer(false, address(0), 0, address(0));
| cardsForSale[_tokenId] = Offer(false, address(0), 0, address(0));
| 30,958 |
215 | // Mints a single PFP. / | function mint(uint256 quantity) external nonReentrant {
require(_time() >= _mintStartTime, "MINT_NOT_STARTED");
require(quantity > 0, "INVALID_QUANTITY");
uint256 totalSupply = totalSupply();
uint256 availableQuantity = Math.min(_maxSupply - totalSupply, quantity);
require(availableQuantity > 0, "MAX_SUPPLY_REACHED");
// Transfer the tokens to the DAO
_token.safeTransferFrom(msg.sender, _dao, _mintPrice * availableQuantity);
// Mint tokens to the purchaser (starting from token ID 1)
uint256 tokenId = totalSupply;
for (uint256 i = 0; i < availableQuantity; i++) {
_safeMint(msg.sender, tokenId + i + 1);
}
}
| function mint(uint256 quantity) external nonReentrant {
require(_time() >= _mintStartTime, "MINT_NOT_STARTED");
require(quantity > 0, "INVALID_QUANTITY");
uint256 totalSupply = totalSupply();
uint256 availableQuantity = Math.min(_maxSupply - totalSupply, quantity);
require(availableQuantity > 0, "MAX_SUPPLY_REACHED");
// Transfer the tokens to the DAO
_token.safeTransferFrom(msg.sender, _dao, _mintPrice * availableQuantity);
// Mint tokens to the purchaser (starting from token ID 1)
uint256 tokenId = totalSupply;
for (uint256 i = 0; i < availableQuantity; i++) {
_safeMint(msg.sender, tokenId + i + 1);
}
}
| 19,601 |
250 | // update voting power which is already stored in the current block | history[history.length - 1].votingPower = uint192(_toVal);
| history[history.length - 1].votingPower = uint192(_toVal);
| 50,639 |
16 | // Event triggered when book gets sent | event BookSent(address _owner);
| event BookSent(address _owner);
| 55,313 |
289 | // delegate call to `approve` | approve(address(0), _tokenId);
| approve(address(0), _tokenId);
| 32,456 |
116 | // 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488Dropsten | );
uint256 constant CARMA_PER_LP = 1693766930000000;
uint256 public lastMintBlock = block.number;
uint256 public totalStaked = 0;
mapping(address => UserInfo) public users;
| );
uint256 constant CARMA_PER_LP = 1693766930000000;
uint256 public lastMintBlock = block.number;
uint256 public totalStaked = 0;
mapping(address => UserInfo) public users;
| 39,706 |
19 | // _destErc20 Destination token/_kyberContract Kyber contract to use | function Burner(address _destErc20, address _kyberContract) public {
// Check inputs
require(_destErc20 != address(0));
require(_kyberContract != address(0));
destErc20 = BurnableErc20(_destErc20);
kyberContract = KyberNetwork(_kyberContract);
}
| function Burner(address _destErc20, address _kyberContract) public {
// Check inputs
require(_destErc20 != address(0));
require(_kyberContract != address(0));
destErc20 = BurnableErc20(_destErc20);
kyberContract = KyberNetwork(_kyberContract);
}
| 32,977 |
19 | // Curve | _tokenIn = _getCurveTokenByIndex(_pool, _poolType, (_encoding >> 163) & 7, _encoding);
_tokenOut = _getCurveTokenByIndex(_pool, _poolType, (_encoding >> 166) & 7, _encoding);
| _tokenIn = _getCurveTokenByIndex(_pool, _poolType, (_encoding >> 163) & 7, _encoding);
_tokenOut = _getCurveTokenByIndex(_pool, _poolType, (_encoding >> 166) & 7, _encoding);
| 16,918 |
8 | // Activate the taxes. | function activateTaxes() external onlyOwner {
taxRate = 2;
taxActive = true;
}
| function activateTaxes() external onlyOwner {
taxRate = 2;
taxActive = true;
}
| 20,460 |
25 | // Description: Changes the treasury wallet address. treasury - Wallet address of treasury wallet. / | function updateTreasury(address treasury) public isOwner {
_treasury = treasury;
}
| function updateTreasury(address treasury) public isOwner {
_treasury = treasury;
}
| 50,601 |
122 | // Read the offerer from calldata and place on the stack. | address offerer;
| address offerer;
| 17,395 |
15 | // Calculate rewards for the msg.sender, check if there are any rewards claim, set unclaimedRewards to 0 and transfer the ERC20 Reward token to the user. | function claimRewards() external {
uint256 rewards = calculateRewards(msg.sender) +
stakers[msg.sender].unclaimedRewards;
require(rewards > 0, "You have no rewards to claim");
stakers[msg.sender].timeOfLastUpdate = block.timestamp;
stakers[msg.sender].unclaimedRewards = 0;
rewardsToken.safeTransfer(msg.sender, rewards);
emit ClaimReward (msg.sender, rewards, block.timestamp);
}
| function claimRewards() external {
uint256 rewards = calculateRewards(msg.sender) +
stakers[msg.sender].unclaimedRewards;
require(rewards > 0, "You have no rewards to claim");
stakers[msg.sender].timeOfLastUpdate = block.timestamp;
stakers[msg.sender].unclaimedRewards = 0;
rewardsToken.safeTransfer(msg.sender, rewards);
emit ClaimReward (msg.sender, rewards, block.timestamp);
}
| 33,659 |
43 | // Emits when ETH is refunded. buyer The address of the buyer. amount The amount of ETH refunded. / | event EthRefunded(address indexed buyer, uint256 amount);
| event EthRefunded(address indexed buyer, uint256 amount);
| 22,977 |
216 | // The contract constructor.//_VERSION A string defining the contract version. | constructor(string _VERSION) public {
VERSION = _VERSION;
}
| constructor(string _VERSION) public {
VERSION = _VERSION;
}
| 78,801 |
12 | // signs aren't the same | float32 memory abs;
if ( aIsNeg ) {
abs.data = a.data & (2**31) - 1;
( r, errorFlags ) = sub( b, abs );
} else {
| float32 memory abs;
if ( aIsNeg ) {
abs.data = a.data & (2**31) - 1;
( r, errorFlags ) = sub( b, abs );
} else {
| 23,179 |
403 | // bytes4(keccak256("AssetProxyDispatchError(uint8,bytes32,bytes)")) | bytes4 internal constant ASSET_PROXY_DISPATCH_ERROR_SELECTOR =
0x488219a6;
| bytes4 internal constant ASSET_PROXY_DISPATCH_ERROR_SELECTOR =
0x488219a6;
| 54,898 |
27 | // Set the owner. | _owner = msg.sender;
_approve(_msgSender(), _routerAddress, type(uint256).max);
_approve(address(this), _routerAddress, type(uint256).max);
_isExcludedFromFees[owner()] = true;
_isExcludedFromFees[address(this)] = true;
_isExcludedFromFees[DEAD] = true;
_liquidityHolders[owner()] = true;
| _owner = msg.sender;
_approve(_msgSender(), _routerAddress, type(uint256).max);
_approve(address(this), _routerAddress, type(uint256).max);
_isExcludedFromFees[owner()] = true;
_isExcludedFromFees[address(this)] = true;
_isExcludedFromFees[DEAD] = true;
_liquidityHolders[owner()] = true;
| 29,416 |