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 |
|---|---|---|---|---|
13 | // Put all funds into Smart Contract | IERC20(_token).transferFrom(msg.sender, address(this), _amount);
| IERC20(_token).transferFrom(msg.sender, address(this), _amount);
| 14,948 |
14 | // if (endorsementParams.requestedCoverageStartDate != 0) { | uint256 coverageStartDate = computeCoverageStartDate(
endorsementParams.requestedCoverageStartDate,
allPolicies[endorsementParams.onChainPolicyId].subscriptionDate,
1
);
allPolicies[endorsementParams.onChainPolicyId].coverageStartDate = coverageStartDate;
allPolicies[endorsementParams.onChainPolicyId].expirationDate = coverageStartDate.addYears(
1,
1
);
| uint256 coverageStartDate = computeCoverageStartDate(
endorsementParams.requestedCoverageStartDate,
allPolicies[endorsementParams.onChainPolicyId].subscriptionDate,
1
);
allPolicies[endorsementParams.onChainPolicyId].coverageStartDate = coverageStartDate;
allPolicies[endorsementParams.onChainPolicyId].expirationDate = coverageStartDate.addYears(
1,
1
);
| 14,046 |
5 | // Correct set of 5 shards should have exactly 2^5-1 for the flag value | require(flag == 31, "Incomplete shards");
| require(flag == 31, "Incomplete shards");
| 45,415 |
8 | // A contract that is authorized to create and resolve insurance claims | address public claimsManager;
| address public claimsManager;
| 17,212 |
115 | // Get the creator payout amount. Fee amount is <= msg.value per above. | uint256 payoutAmount;
unchecked {
payoutAmount = msg.value - feeAmount;
}
| uint256 payoutAmount;
unchecked {
payoutAmount = msg.value - feeAmount;
}
| 30,240 |
12 | // check if lock exists | (bool lockExists, , ) = IUnlock(unlockAddress).locks(lock);
if (!lockExists) {
revert LockDoesntExist(lock);
}
| (bool lockExists, , ) = IUnlock(unlockAddress).locks(lock);
if (!lockExists) {
revert LockDoesntExist(lock);
}
| 755 |
34 | // Adds two numbers and checks for overflow before returning./ Does not throw./a First number/b Second number/ return err False normally, or true if there is overflow/ return res The sum of a and b, or 0 if there is overflow | function plus(uint256 a, uint256 b) public pure returns (bool err, uint256 res) {
assembly{
res := add(a,b)
switch and(eq(sub(res,b), a), or(gt(res,b),eq(res,b)))
case 0 {
err := 1
res := 0
}
}
}
| function plus(uint256 a, uint256 b) public pure returns (bool err, uint256 res) {
assembly{
res := add(a,b)
switch and(eq(sub(res,b), a), or(gt(res,b),eq(res,b)))
case 0 {
err := 1
res := 0
}
}
}
| 33,409 |
2 | // describe a single blockchain states/stateHash the hash with the reputation state/hashType the type of hash. currently just 0 = merkle tree root hash/totalSupply the totalSupply at the blockchain/blockNumber the effective blocknumber | struct BlockchainState {
bytes32 stateHash;
uint256 hashType;
uint256 totalSupply;
uint256 blockNumber;
uint256[5] __reserevedSpace;
}
| struct BlockchainState {
bytes32 stateHash;
uint256 hashType;
uint256 totalSupply;
uint256 blockNumber;
uint256[5] __reserevedSpace;
}
| 39,572 |
263 | // Function to set NFT Price/ | function setNFTPrice(uint256 _price) external onlyOwner {
require(_price <= MAXNFTPrice, "cannot set price too high");
NFTPrice = _price;
}
| function setNFTPrice(uint256 _price) external onlyOwner {
require(_price <= MAXNFTPrice, "cannot set price too high");
NFTPrice = _price;
}
| 61,202 |
29 | // Drops feeds with indexes `feedIndexes` from being feeds./Only callable by auth'ed address./feedIndexes The feed's index identifiers of the feeds to drop. | function drop(uint[] memory feedIndexes) external;
| function drop(uint[] memory feedIndexes) external;
| 28,334 |
109 | // Withdraws yCRV from the investment pool that mints crops./ | function withdrawYCrvFromPool(uint256 amount) internal {
Gauge(pool).withdraw(
Math.min(Gauge(pool).balanceOf(address(this)), amount)
);
}
| function withdrawYCrvFromPool(uint256 amount) internal {
Gauge(pool).withdraw(
Math.min(Gauge(pool).balanceOf(address(this)), amount)
);
}
| 10,866 |
48 | // Removes address from authorized contracts/ | function deauthorizeCaller(address contractAddress) external requireContractOwner {
delete authorizedContracts[contractAddress];
}
| function deauthorizeCaller(address contractAddress) external requireContractOwner {
delete authorizedContracts[contractAddress];
}
| 40,526 |
213 | // Executes action on the request to deposit tokens relayed from the other network _recipient address of tokens receiver _value amount of bridged tokens / | function executeActionOnBridgedTokens(address _token, address _recipient, uint256 _value) internal {
bytes32 _messageId = messageId();
uint256 valueToMint = _value;
uint256 fee = _distributeFee(FOREIGN_TO_HOME_FEE, _token, valueToMint);
if (fee > 0) {
emit FeeDistributed(fee, _token, _messageId);
valueToMint = valueToMint.sub(fee);
}
IBurnableMintableERC677Token(_token).mint(_recipient, valueToMint);
emit TokensBridged(_token, _recipient, valueToMint, _messageId);
}
| function executeActionOnBridgedTokens(address _token, address _recipient, uint256 _value) internal {
bytes32 _messageId = messageId();
uint256 valueToMint = _value;
uint256 fee = _distributeFee(FOREIGN_TO_HOME_FEE, _token, valueToMint);
if (fee > 0) {
emit FeeDistributed(fee, _token, _messageId);
valueToMint = valueToMint.sub(fee);
}
IBurnableMintableERC677Token(_token).mint(_recipient, valueToMint);
emit TokensBridged(_token, _recipient, valueToMint, _messageId);
}
| 42,585 |
54 | // An event to make the transfer easy to find on the blockchain | Transfer(_from, _to, _amount);
return true;
| Transfer(_from, _to, _amount);
return true;
| 19,884 |
227 | // returns all closed auctions | function getClosedAuctions() public view returns(uint256[] memory) {
uint256[] memory returnArray = new uint256[](auctionCounter - openAuctions);
uint256 j = 0;
for(uint256 i = 1; i <= auctionCounter; i++) {
if(auctions[i].resolved) {
returnArray[j] = i;
j++;
}
}
return returnArray;
}
| function getClosedAuctions() public view returns(uint256[] memory) {
uint256[] memory returnArray = new uint256[](auctionCounter - openAuctions);
uint256 j = 0;
for(uint256 i = 1; i <= auctionCounter; i++) {
if(auctions[i].resolved) {
returnArray[j] = i;
j++;
}
}
return returnArray;
}
| 30,357 |
9 | // Purchase a token as the public./_mintAmount The amount the person minting has requested to mint. | function purchasePublic(uint256 _mintAmount)
external
payable
nonReentrant
isNotPaused
mintAmountGreaterThanZero(_mintAmount)
DoesntExceedLimit(_mintAmount)
| function purchasePublic(uint256 _mintAmount)
external
payable
nonReentrant
isNotPaused
mintAmountGreaterThanZero(_mintAmount)
DoesntExceedLimit(_mintAmount)
| 78,066 |
93 | // only pool owner can change pool owner key | function setPoolOwner(uint poolId, address newOwner) external poolOwnerOnly(poolId) {
Pool storage pool = pools[poolId];
pool.poolOwner = newOwner;
}
| function setPoolOwner(uint poolId, address newOwner) external poolOwnerOnly(poolId) {
Pool storage pool = pools[poolId];
pool.poolOwner = newOwner;
}
| 17,187 |
17 | // Vote to a proposal._proposalId The proposal id. / | function vote(uint _proposalId) external onlyVoters {
require(workflowStatus == WorkflowStatus.VotingSessionStarted, "The workflow status not allowed you to vote.");
require(_proposalId < proposals.length, "Proposal not found. Please enter a valid id.");
require(!voters[msg.sender].hasVoted, "You have already voted.");
voters[msg.sender].votedProposalId = _proposalId;
voters[msg.sender].hasVoted = true;
proposals[_proposalId].voteCount++;
emit Voted(msg.sender, _proposalId);
}
| function vote(uint _proposalId) external onlyVoters {
require(workflowStatus == WorkflowStatus.VotingSessionStarted, "The workflow status not allowed you to vote.");
require(_proposalId < proposals.length, "Proposal not found. Please enter a valid id.");
require(!voters[msg.sender].hasVoted, "You have already voted.");
voters[msg.sender].votedProposalId = _proposalId;
voters[msg.sender].hasVoted = true;
proposals[_proposalId].voteCount++;
emit Voted(msg.sender, _proposalId);
}
| 55,724 |
148 | // query support of each interface in interfaceIds | for (uint256 i = 0; i < interfaceIds.length; i++) {
interfaceIdsSupported[i] = _supportsERC165Interface(account, interfaceIds[i]);
}
| for (uint256 i = 0; i < interfaceIds.length; i++) {
interfaceIdsSupported[i] = _supportsERC165Interface(account, interfaceIds[i]);
}
| 9,851 |
133 | // Mainnet address of the `Dai` (multi-collateral) contract | address constant private DAI_ADDRESS = 0x6B175474E89094C44Da98b954EedeAC495271d0F;
| address constant private DAI_ADDRESS = 0x6B175474E89094C44Da98b954EedeAC495271d0F;
| 34,342 |
16 | // Reserved storage space to allow for layout changes in the future. | uint256[50] private ______gap;
| uint256[50] private ______gap;
| 2,389 |
9 | // 查询用户自己所有的订单return claims bytes32[] : 由orderID组成的列表 / | function myOrders() view public returns(bytes32[])
| function myOrders() view public returns(bytes32[])
| 29,861 |
37 | // personal valuation and minimum should be set to the proper granularity, only three most significant values can be non-zero. reduces the number of possible valuation buckets in the linked list | uint256 digits = numDigits(_personalCap);
if(digits > 3) {
require((_personalCap % (10**(digits - 3))) == 0);
}
| uint256 digits = numDigits(_personalCap);
if(digits > 3) {
require((_personalCap % (10**(digits - 3))) == 0);
}
| 45,473 |
21 | // simulate a redemption of given quantity of shares shareAmount quantity of shares to redeemreturn assetAmount quantity of assets to withdraw / | function _previewRedeem(uint256 shareAmount)
internal
view
virtual
returns (uint256 assetAmount)
| function _previewRedeem(uint256 shareAmount)
internal
view
virtual
returns (uint256 assetAmount)
| 27,611 |
38 | // Timestamp when this contract was deployed | uint256 public immutable override deploymentTime;
| uint256 public immutable override deploymentTime;
| 34,873 |
143 | // Intializer _futureAddress the address of the corresponding future _adminAddress the address of the ACR admin / | function initialize(address _futureAddress, address _adminAddress) external;
| function initialize(address _futureAddress, address _adminAddress) external;
| 41,297 |
68 | // Cache the number of founders | uint256 numFounders = settings.numFounders;
| uint256 numFounders = settings.numFounders;
| 29,934 |
21 | // calculateMintAmount() is not used because deposit value is needed for the event | uint256 depositValue = getValueFromUnderlyerAmount(depositAmount);
uint256 poolTotalValue = getPoolTotalValue();
uint256 mintAmount = _calculateMintAmount(depositValue, poolTotalValue);
_mint(msg.sender, mintAmount);
underlyer.safeTransferFrom(msg.sender, address(this), depositAmount);
emit DepositedAPT(
msg.sender,
underlyer,
| uint256 depositValue = getValueFromUnderlyerAmount(depositAmount);
uint256 poolTotalValue = getPoolTotalValue();
uint256 mintAmount = _calculateMintAmount(depositValue, poolTotalValue);
_mint(msg.sender, mintAmount);
underlyer.safeTransferFrom(msg.sender, address(this), depositAmount);
emit DepositedAPT(
msg.sender,
underlyer,
| 45,595 |
99 | // Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing/ Returns the downcasted uint128 from uint256, reverting onoverflow (when the input is greater than largest uint128). Counterpart to Solidity's `uint128` operator. Requirements: - input must fit into 128 bits / | function toUint128(uint256 value) internal pure returns (uint128) {
require(value < 2**128, "SafeCast: value doesn\'t fit in 128 bits");
return uint128(value);
}
| function toUint128(uint256 value) internal pure returns (uint128) {
require(value < 2**128, "SafeCast: value doesn\'t fit in 128 bits");
return uint128(value);
}
| 10,370 |
23 | // The standard EIP-20 transfer event | event Transfer(address indexed from, address indexed to, uint amount);
| event Transfer(address indexed from, address indexed to, uint amount);
| 4,065 |
50 | // Check if paused | require(!paused && !pausedProvided.isPaused(), "contract paused");
| require(!paused && !pausedProvided.isPaused(), "contract paused");
| 40,066 |
14 | // Interactions | uint256 tokensToTransfer = (theFraction*_lpTokenBalance())/ONE_IN_TEN_DECIMALS;
IERC20(CLIPPER_EXCHANGE).safeTransfer(msg.sender, tokensToTransfer);
emit FeesTaken(entitledFeesInDollars, averagePoolBalanceInDollars, tokensToTransfer);
| uint256 tokensToTransfer = (theFraction*_lpTokenBalance())/ONE_IN_TEN_DECIMALS;
IERC20(CLIPPER_EXCHANGE).safeTransfer(msg.sender, tokensToTransfer);
emit FeesTaken(entitledFeesInDollars, averagePoolBalanceInDollars, tokensToTransfer);
| 13,726 |
119 | // only locker can remove time lock / | function removeTimeLock(address account, uint8 index) public onlyOwner whenNotPaused {
_removeTimeLock(account, index);
}
| function removeTimeLock(address account, uint8 index) public onlyOwner whenNotPaused {
_removeTimeLock(account, index);
}
| 25,826 |
162 | // only if CS was not ended | require(now < closingTime);
| require(now < closingTime);
| 14,541 |
7 | // this is just a normal mapping, but which holds size and you can specify slot// | contract EnhancedMap is SlotData {
constructor(){}
//set value to 0x00 to delete
function sysEnhancedMapSet(bytes32 slot, bytes32 key, bytes32 value) internal {
require(key != bytes32(0x00), "sysEnhancedMapSet, notEmptyKey");
sysMapSet(slot, key, value);
}
function sysEnhancedMapAdd(bytes32 slot, bytes32 key, bytes32 value) internal {
require(key != bytes32(0x00), "sysEnhancedMapAdd, notEmptyKey");
require(value != bytes32(0x00), "EnhancedMap add, the value shouldn't be empty");
require(sysMapGet(slot, key) == bytes32(0x00), "EnhancedMap, the key already has value, can't add duplicate key");
sysMapSet(slot, key, value);
}
function sysEnhancedMapDel(bytes32 slot, bytes32 key) internal {
require(key != bytes32(0x00), "sysEnhancedMapDel, notEmptyKey");
require(sysMapGet(slot, key) != bytes32(0x00), "sysEnhancedMapDel, the key doesn't has value, can't delete empty key");
sysMapSet(slot, key, bytes32(0x00));
}
function sysEnhancedMapReplace(bytes32 slot, bytes32 key, bytes32 value) public {
require(key != bytes32(0x00), "sysEnhancedMapReplace, notEmptyKey");
require(value != bytes32(0x00), "EnhancedMap replace, the value shouldn't be empty");
require(sysMapGet(slot, key) != bytes32(0x00), "EnhancedMap, the key doesn't has value, can't replace it");
sysMapSet(slot, key, value);
}
function sysEnhancedMapGet(bytes32 slot, bytes32 key) internal view returns (bytes32){
require(key != bytes32(0x00), "sysEnhancedMapGet, notEmptyKey");
return sysMapGet(slot, key);
}
function sysEnhancedMapSize(bytes32 slot) internal view returns (uint256){
return sysMapLen(slot);
}
}
| contract EnhancedMap is SlotData {
constructor(){}
//set value to 0x00 to delete
function sysEnhancedMapSet(bytes32 slot, bytes32 key, bytes32 value) internal {
require(key != bytes32(0x00), "sysEnhancedMapSet, notEmptyKey");
sysMapSet(slot, key, value);
}
function sysEnhancedMapAdd(bytes32 slot, bytes32 key, bytes32 value) internal {
require(key != bytes32(0x00), "sysEnhancedMapAdd, notEmptyKey");
require(value != bytes32(0x00), "EnhancedMap add, the value shouldn't be empty");
require(sysMapGet(slot, key) == bytes32(0x00), "EnhancedMap, the key already has value, can't add duplicate key");
sysMapSet(slot, key, value);
}
function sysEnhancedMapDel(bytes32 slot, bytes32 key) internal {
require(key != bytes32(0x00), "sysEnhancedMapDel, notEmptyKey");
require(sysMapGet(slot, key) != bytes32(0x00), "sysEnhancedMapDel, the key doesn't has value, can't delete empty key");
sysMapSet(slot, key, bytes32(0x00));
}
function sysEnhancedMapReplace(bytes32 slot, bytes32 key, bytes32 value) public {
require(key != bytes32(0x00), "sysEnhancedMapReplace, notEmptyKey");
require(value != bytes32(0x00), "EnhancedMap replace, the value shouldn't be empty");
require(sysMapGet(slot, key) != bytes32(0x00), "EnhancedMap, the key doesn't has value, can't replace it");
sysMapSet(slot, key, value);
}
function sysEnhancedMapGet(bytes32 slot, bytes32 key) internal view returns (bytes32){
require(key != bytes32(0x00), "sysEnhancedMapGet, notEmptyKey");
return sysMapGet(slot, key);
}
function sysEnhancedMapSize(bytes32 slot) internal view returns (uint256){
return sysMapLen(slot);
}
}
| 36,738 |
12 | // threads | mapping(uint=>Thread) private threads;
mapping(address=>uint[]) private userThreads;
mapping(uint=>mapping(address=>bool)) private threadLikes;
| mapping(uint=>Thread) private threads;
mapping(address=>uint[]) private userThreads;
mapping(uint=>mapping(address=>bool)) private threadLikes;
| 24,099 |
23 | // Gets the gas amount for the estimateFees function Please override this to however you wish to calculate your gas usage on destiniation chain _payload The payload to be sent to the destination chain / |
function getEstGasAmount(bytes memory _payload)
public
view
returns (uint256)
|
function getEstGasAmount(bytes memory _payload)
public
view
returns (uint256)
| 10,629 |
22 | // Global constructor for factory | constructor() {
_pricing.whoCanMint = WhoCanMint.NOT_FOR_SALE;
_disableInitializers();
}
| constructor() {
_pricing.whoCanMint = WhoCanMint.NOT_FOR_SALE;
_disableInitializers();
}
| 10,285 |
302 | // Disputes a price request with an active proposal on another address' behalf. Note: this address willreceive any rewards that come from this dispute. However, any bonds are pulled from the caller. identifier price identifier to identify the existing request. timestamp timestamp to identify the existing request. ancillaryData ancillary data of the price being requested. request price request parameters whose hash must match the request that the caller wants to dispute. disputer address to set as the disputer. requester sender of the initial price request.return totalBond the amount that's pulled from the caller's wallet as a bond. The bond will be | function disputePriceFor(
bytes32 identifier,
uint32 timestamp,
bytes memory ancillaryData,
Request memory request,
address disputer,
address requester
| function disputePriceFor(
bytes32 identifier,
uint32 timestamp,
bytes memory ancillaryData,
Request memory request,
address disputer,
address requester
| 32,593 |
102 | // We resume normal operations | swapping = false;
| swapping = false;
| 11,092 |
3 | // Returns the current address of the INFT instancereturn _nftAddress - address of the INFT instance / | function getNFTAddress() external view returns (address) {
return LibDiamondDapes.diamondDapesStorage().nftAddress;
}
| function getNFTAddress() external view returns (address) {
return LibDiamondDapes.diamondDapesStorage().nftAddress;
}
| 17,515 |
24 | // We can only charge a fees if the borrower has reported extra free funds, if it's the first report at this block and only if the borrower was registered some time ago | if (
extraFreeFunds > 0 &&
borrowersData[msg.sender].lastReportTimestamp < block.timestamp && // solhint-disable-line not-rely-on-time
borrowersData[msg.sender].activationTimestamp < block.timestamp // solhint-disable-line not-rely-on-time
) {
chargedFees = _chargeFees(extraFreeFunds);
}
| if (
extraFreeFunds > 0 &&
borrowersData[msg.sender].lastReportTimestamp < block.timestamp && // solhint-disable-line not-rely-on-time
borrowersData[msg.sender].activationTimestamp < block.timestamp // solhint-disable-line not-rely-on-time
) {
chargedFees = _chargeFees(extraFreeFunds);
}
| 15,308 |
15 | // get the claim details for the corresponding nonce from protocol contract | function _claimDetails() private view returns (uint16 _payoutNumerator, uint16 _payoutDenominator, uint48 _incidentTimestamp, uint48 _claimEnactedTimestamp) {
return IProtocol(owner()).claimDetails(claimNonce);
}
| function _claimDetails() private view returns (uint16 _payoutNumerator, uint16 _payoutDenominator, uint48 _incidentTimestamp, uint48 _claimEnactedTimestamp) {
return IProtocol(owner()).claimDetails(claimNonce);
}
| 34,713 |
141 | // This makes the invite code claimed | inviteCodeList[_inviteCode][address(tokenAddress)][_msgSender()] = false;
return poolId;
| inviteCodeList[_inviteCode][address(tokenAddress)][_msgSender()] = false;
return poolId;
| 34,289 |
135 | // Returns a fraction roughly equaling E^((1/2)^x) for integer x / | function getPrecomputedEToTheHalfToThe(
uint256 x
)
internal
pure
returns (Fraction.Fraction128 memory)
| function getPrecomputedEToTheHalfToThe(
uint256 x
)
internal
pure
returns (Fraction.Fraction128 memory)
| 17,751 |
33 | // memberAddress => numDelegateCheckpoints | mapping(address => uint32) numCheckpoints;
DaoState public state;
| mapping(address => uint32) numCheckpoints;
DaoState public state;
| 31,411 |
34 | // Check eligibility | if (details.distributions >= maxTimesDistributeAllowed)
revert MaxDistributionsFromAddress();
if (
veRiseAddress.balanceOf(account) == 0 &&
!checkNftHolder(account)
) revert NotAllowedToDistribute();
| if (details.distributions >= maxTimesDistributeAllowed)
revert MaxDistributionsFromAddress();
if (
veRiseAddress.balanceOf(account) == 0 &&
!checkNftHolder(account)
) revert NotAllowedToDistribute();
| 40,517 |
344 | // Allow the amount to be withdrawn using `withdrawFromApprovedWithdrawal`. | S.amountWithdrawable[to][tokenID] = S.amountWithdrawable[to][tokenID].add(amount);
| S.amountWithdrawable[to][tokenID] = S.amountWithdrawable[to][tokenID].add(amount);
| 43,087 |
79 | // y.safeTransfer(msg.sender, amount); | y.transfer(msg.sender, amount);
| y.transfer(msg.sender, amount);
| 35,381 |
111 | // rewad per block in wei | uint256 public rewardPerBlock;
| uint256 public rewardPerBlock;
| 8,035 |
29 | // Calculate x^y assuming 0^0 is 1, where x is unsigned 129.127 fixed pointnumber and y is unsigned 256-bit integer number.Revert on overflow.x unsigned 129.127-bit fixed point number y uint256 valuereturn unsigned 129.127-bit fixed point number / | function powu (uint256 x, uint256 y) private pure returns (uint256) {
if (y == 0) return 0x80000000000000000000000000000000;
else if (x == 0) return 0;
else {
int256 msb = 0;
uint256 xc = x;
if (xc >= 0x100000000000000000000000000000000) { xc >>= 128; msb += 128; }
if (xc >= 0x10000000000000000) { xc >>= 64; msb += 64; }
if (xc >= 0x100000000) { xc >>= 32; msb += 32; }
if (xc >= 0x10000) { xc >>= 16; msb += 16; }
if (xc >= 0x100) { xc >>= 8; msb += 8; }
if (xc >= 0x10) { xc >>= 4; msb += 4; }
if (xc >= 0x4) { xc >>= 2; msb += 2; }
if (xc >= 0x2) msb += 1; // No need to shift xc anymore
int256 xe = msb - 127;
if (xe > 0) x >>= xe;
else x <<= -xe;
uint256 result = 0x80000000000000000000000000000000;
int256 re = 0;
while (y > 0) {
if (y & 1 > 0) {
result = result * x;
y -= 1;
re += xe;
if (result >=
0x8000000000000000000000000000000000000000000000000000000000000000) {
result >>= 128;
re += 1;
} else result >>= 127;
if (re < -127) return 0; // Underflow
require (re < 128); // Overflow
} else {
x = x * x;
y >>= 1;
xe <<= 1;
if (x >=
0x8000000000000000000000000000000000000000000000000000000000000000) {
x >>= 128;
xe += 1;
} else x >>= 127;
if (xe < -127) return 0; // Underflow
require (xe < 128); // Overflow
}
}
if (re > 0) result <<= re;
else if (re < 0) result >>= -re;
return result;
}
}
| function powu (uint256 x, uint256 y) private pure returns (uint256) {
if (y == 0) return 0x80000000000000000000000000000000;
else if (x == 0) return 0;
else {
int256 msb = 0;
uint256 xc = x;
if (xc >= 0x100000000000000000000000000000000) { xc >>= 128; msb += 128; }
if (xc >= 0x10000000000000000) { xc >>= 64; msb += 64; }
if (xc >= 0x100000000) { xc >>= 32; msb += 32; }
if (xc >= 0x10000) { xc >>= 16; msb += 16; }
if (xc >= 0x100) { xc >>= 8; msb += 8; }
if (xc >= 0x10) { xc >>= 4; msb += 4; }
if (xc >= 0x4) { xc >>= 2; msb += 2; }
if (xc >= 0x2) msb += 1; // No need to shift xc anymore
int256 xe = msb - 127;
if (xe > 0) x >>= xe;
else x <<= -xe;
uint256 result = 0x80000000000000000000000000000000;
int256 re = 0;
while (y > 0) {
if (y & 1 > 0) {
result = result * x;
y -= 1;
re += xe;
if (result >=
0x8000000000000000000000000000000000000000000000000000000000000000) {
result >>= 128;
re += 1;
} else result >>= 127;
if (re < -127) return 0; // Underflow
require (re < 128); // Overflow
} else {
x = x * x;
y >>= 1;
xe <<= 1;
if (x >=
0x8000000000000000000000000000000000000000000000000000000000000000) {
x >>= 128;
xe += 1;
} else x >>= 127;
if (xe < -127) return 0; // Underflow
require (xe < 128); // Overflow
}
}
if (re > 0) result <<= re;
else if (re < 0) result >>= -re;
return result;
}
}
| 31,621 |
11 | // (etherBalanceOf[msg.sender] / 1e16) - calc. how much interest will be (based on deposit) for min. deposit (0.01 ETH), (etherBalanceOf[msg.sender] / 1e16) = 1 (the same, 31668017/s) for deposit 0.02 ETH, (etherBalanceOf[msg.sender] / 1e16) = 2 (doubled, (231668017)/s) | uint interestPerSecond = 31668017 * (etherBalanceOf[msg.sender] / 1e16);
uint interest = interestPerSecond * depositTime;
| uint interestPerSecond = 31668017 * (etherBalanceOf[msg.sender] / 1e16);
uint interest = interestPerSecond * depositTime;
| 19,316 |
3 | // 제품 등록의 수를 리턴합니다. | function getNumOfProducts() public constant returns(uint8) {
return numberOfProducts;
}
| function getNumOfProducts() public constant returns(uint8) {
return numberOfProducts;
}
| 32,476 |
0 | // Constants state |
bytes32 private constant EMPTY_STRING_HASH = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
|
bytes32 private constant EMPTY_STRING_HASH = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
| 13,625 |
118 | // Delegate call to to address to transfer to value amount to transfer origSender original msg.sender on delegate contractreturn success / | function delegateTransfer(
address to,
uint256 value,
address origSender
| function delegateTransfer(
address to,
uint256 value,
address origSender
| 68,308 |
333 | // Swap imbalanced token as long as we haven't used the entire amountSpecified and haven't reached the price limit | pool.swap(
address(this),
zeroForOne,
amountSpecified,
sqrtPriceLimitX96,
| pool.swap(
address(this),
zeroForOne,
amountSpecified,
sqrtPriceLimitX96,
| 13,197 |
38 | // --------------------------------------------------------------------------- setConfig / getConfig are User Application (UA) functions to specify Oracle, Relayer, blockConfirmations, libraryVersion | function setConfig(uint16 _chainId, address _userApplication, uint _configType, bytes calldata _config) external;
function getConfig(
uint16 _chainId,
address _userApplication,
uint _configType
) external view returns (bytes memory);
| function setConfig(uint16 _chainId, address _userApplication, uint _configType, bytes calldata _config) external;
function getConfig(
uint16 _chainId,
address _userApplication,
uint _configType
) external view returns (bytes memory);
| 12,840 |
207 | // Getter for the next performance fee factor of one futureVault _futureVault the address of the futureVaultreturn the next performance fee factor of the futureVault / | function getNextPerformanceFeeFactor(address _futureVault) external view returns (uint256);
| function getNextPerformanceFeeFactor(address _futureVault) external view returns (uint256);
| 20,534 |
136 | // update the bool mapping of past and current stakers | hasStaked[msg.sender] = true;
totalStakedFunds = totalStakedFunds.add(_amount);
| hasStaked[msg.sender] = true;
totalStakedFunds = totalStakedFunds.add(_amount);
| 24,957 |
118 | // bond: | function convert2BondAmount(address b, address t, uint256 amount)
external
view
returns (uint256);
| function convert2BondAmount(address b, address t, uint256 amount)
external
view
returns (uint256);
| 36,069 |
142 | // = keccak256("TransferWithAuthorization(address from,address to,uint256 value,uint256 validAfter,uint256 validBefore,bytes32 nonce)") | bytes32
public constant APPROVE_WITH_AUTHORIZATION_TYPEHASH = 0x808c10407a796f3ef2c7ea38c0638ea9d2b8a1c63e3ca9e1f56ce84ae59df73c;
| bytes32
public constant APPROVE_WITH_AUTHORIZATION_TYPEHASH = 0x808c10407a796f3ef2c7ea38c0638ea9d2b8a1c63e3ca9e1f56ce84ae59df73c;
| 10,571 |
113 | // Produce the sha256 digest of the concatenated contents of multiple views. memViewsThe viewsreturnbytes32 - The sha256 digest / | function joinSha2(bytes29[] memory memViews)
internal
view
returns (bytes32)
| function joinSha2(bytes29[] memory memViews)
internal
view
returns (bytes32)
| 16,897 |
29 | // ============ INTERNALS ============ |
function _calRewardToken(address stakingToken_, uint256 amount_)
internal
view
returns (uint256)
|
function _calRewardToken(address stakingToken_, uint256 amount_)
internal
view
returns (uint256)
| 12,866 |
31 | // Multiplies two numbers, throws on overflow./ | function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
| function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
| 34 |
21 | // Event that notifies clients about the amount approved to be spent owner Address owner of the approved funds spender The address authorized to spend the funds value Amount of tokens approved / | event Approval(
| event Approval(
| 16,256 |
7 | // this function gets the specified transaction object/ THis function will retrieve the transaction with the id `_transactionId`/ _transactionId the ID of the transaction to retrieve/return Returns the source address/return Returns the destination address/return Returns the value sent/return Returns the data payload/return Returns true for a complete transaction, otherwise false | function getTransaction(uint _transactionId) public view
returns
(
address source,
address destination,
uint value,
bytes memory data,
bool complete,
bool cancelled
)
| function getTransaction(uint _transactionId) public view
returns
(
address source,
address destination,
uint value,
bytes memory data,
bool complete,
bool cancelled
)
| 41,684 |
7 | // Only the whitelist controller can whitelist addresses. | address public whitelistingAddress;
| address public whitelistingAddress;
| 8,631 |
226 | // ========== MUTATIVE FUNCTIONS ========== // ---------- SETTERS ---------- / | function setUtilisationMultiplier(uint _utilisationMultiplier) public onlyOwner {
require(_utilisationMultiplier > 0, "Must be greater than 0");
utilisationMultiplier = _utilisationMultiplier;
}
| function setUtilisationMultiplier(uint _utilisationMultiplier) public onlyOwner {
require(_utilisationMultiplier > 0, "Must be greater than 0");
utilisationMultiplier = _utilisationMultiplier;
}
| 690 |
33 | // Time pause was called | uint public timePaused = block.timestamp;
| uint public timePaused = block.timestamp;
| 43,784 |
250 | // Return the log in base 10, following the selected rounding direction, of a positive value.Returns 0 if given 0. / | function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);
}
}
| function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);
}
}
| 496 |
175 | // pre ico functions: | uint public constant PRE_ICO_START = 1528243201; //1528344001; //1528228860-no; //06/06/2018 UTC-4 UTC-0
uint public constant PRE_ICO_FINISH = 1530403199; //1530417599; //1530388740-no; //30/06/2018 UTC-4 UTC-0
uint public constant PRE_ICO_MIN_CAP = 0;
uint public constant PRE_ICO_MAX_CAP = 5000000 ether; //tokens
uint public preIcoTokensSold;
| uint public constant PRE_ICO_START = 1528243201; //1528344001; //1528228860-no; //06/06/2018 UTC-4 UTC-0
uint public constant PRE_ICO_FINISH = 1530403199; //1530417599; //1530388740-no; //30/06/2018 UTC-4 UTC-0
uint public constant PRE_ICO_MIN_CAP = 0;
uint public constant PRE_ICO_MAX_CAP = 5000000 ether; //tokens
uint public preIcoTokensSold;
| 27,718 |
127 | // harvest rewards from multiple pools for the sender / | function harvestMultiplePools(uint256[] calldata _pids) external;
| function harvestMultiplePools(uint256[] calldata _pids) external;
| 39,804 |
147 | // ESCBCoin constructor just parametrizes the MiniMeIrrVesDivToken constructor | function ESCBCoin (
address _tokenFactory
) public MiniMeIrrVesDivToken(
_tokenFactory,
0x0, // no parent token
0, // no snapshot block number from parent
"ESCB token", // Token name
18, // Decimals
"ESCB", // Symbol
true // Enable transfers
| function ESCBCoin (
address _tokenFactory
) public MiniMeIrrVesDivToken(
_tokenFactory,
0x0, // no parent token
0, // no snapshot block number from parent
"ESCB token", // Token name
18, // Decimals
"ESCB", // Symbol
true // Enable transfers
| 33,830 |
51 | // NEST voting cancellation/ | function nestVoteCancel() public {
require(address(msg.sender) == address(tx.origin), "It can't be a contract");
require(now <= _endTime, "Voting time exceeded");
require(!_effective, "Vote in force");
require(_personalAmount[address(tx.origin)] > 0, "No vote");
_totalAmount = _totalAmount.sub(_personalAmount[address(tx.origin)]);
_personalAmount[address(tx.origin)] = 0;
}
| function nestVoteCancel() public {
require(address(msg.sender) == address(tx.origin), "It can't be a contract");
require(now <= _endTime, "Voting time exceeded");
require(!_effective, "Vote in force");
require(_personalAmount[address(tx.origin)] > 0, "No vote");
_totalAmount = _totalAmount.sub(_personalAmount[address(tx.origin)]);
_personalAmount[address(tx.origin)] = 0;
}
| 24,784 |
14 | // GovernancePhases | bytes32 internal KEY_GOVERNANCE; // 2.x
bytes32 internal KEY_STAKING; // 1.2
bytes32 internal KEY_PROXY_ADMIN; // 1.0
| bytes32 internal KEY_GOVERNANCE; // 2.x
bytes32 internal KEY_STAKING; // 1.2
bytes32 internal KEY_PROXY_ADMIN; // 1.0
| 73,361 |
17 | // lottery wallet | address public lotteryWallet = 0x1d5393bda55199494b7845F8a2c7BA986145BC02;
| address public lotteryWallet = 0x1d5393bda55199494b7845F8a2c7BA986145BC02;
| 7,044 |
29 | // Contract constructor. / | constructor()
| constructor()
| 38,209 |
206 | // Check if we're longer in a non-initial state while shutdown than allowed | if (result == false && isShutdown(S) && !isInInitialState(S)) {
| if (result == false && isShutdown(S) && !isInInitialState(S)) {
| 26,411 |
6 | // withdraws to the governance address if it has enough vote amount / | function withdrawToGovernanceAddress(address payable multisig)
external
nonReentrant
| function withdrawToGovernanceAddress(address payable multisig)
external
nonReentrant
| 47,435 |
13 | // add chains to the whitelist/chains chains to add/exchangeRatesFromPow exchange rates for `chains` as a power of 10./ exchange rate is a multiplier that fixes the difference/ between decimals on different chains | function addChains(string[] calldata chains, uint256[] calldata exchangeRatesFromPow)
external
onlyRole(MANAGER_ROLE)
| function addChains(string[] calldata chains, uint256[] calldata exchangeRatesFromPow)
external
onlyRole(MANAGER_ROLE)
| 1,993 |
26 | // Whitelisted address transfer ions from other address Send `_value` ions to `_to` on behalf of `_from`_from The address of the sender _to The address of the recipient _value the amount to send / | function whitelistTransferFrom(address _from, address _to, uint256 _value) public inWhitelist returns (bool success) {
_transfer(_from, _to, _value);
return true;
}
| function whitelistTransferFrom(address _from, address _to, uint256 _value) public inWhitelist returns (bool success) {
_transfer(_from, _to, _value);
return true;
}
| 46,218 |
24 | // Record the amount of ETH sent as the contract&39;s current value. | contract_eth_value = this.balance;
| contract_eth_value = this.balance;
| 30,935 |
70 | // Implements the KYCBase releaseTokensTo function to mint tokens for an investor. Called after the KYC process has passed.return A bollean that indicates if the operation was successful. / | function releaseTokensTo(address buyer) internal returns(bool) {
require(validPurchase());
uint256 overflowTokens;
uint256 refundWeiAmount;
uint256 weiAmount = msg.value;
uint256 tokenAmount = weiAmount.mul(price());
if (tokenAmount >= availableTokens) {
capReached = true;
overflowTokens = tokenAmount.sub(availableTokens);
tokenAmount = tokenAmount.sub(overflowTokens);
refundWeiAmount = overflowTokens.div(price());
weiAmount = weiAmount.sub(refundWeiAmount);
buyer.transfer(refundWeiAmount);
}
weiRaised = weiRaised.add(weiAmount);
tokensSold = tokensSold.add(tokenAmount);
availableTokens = availableTokens.sub(tokenAmount);
mintTokens(buyer, tokenAmount);
forwardFunds(weiAmount);
return true;
}
| function releaseTokensTo(address buyer) internal returns(bool) {
require(validPurchase());
uint256 overflowTokens;
uint256 refundWeiAmount;
uint256 weiAmount = msg.value;
uint256 tokenAmount = weiAmount.mul(price());
if (tokenAmount >= availableTokens) {
capReached = true;
overflowTokens = tokenAmount.sub(availableTokens);
tokenAmount = tokenAmount.sub(overflowTokens);
refundWeiAmount = overflowTokens.div(price());
weiAmount = weiAmount.sub(refundWeiAmount);
buyer.transfer(refundWeiAmount);
}
weiRaised = weiRaised.add(weiAmount);
tokensSold = tokensSold.add(tokenAmount);
availableTokens = availableTokens.sub(tokenAmount);
mintTokens(buyer, tokenAmount);
forwardFunds(weiAmount);
return true;
}
| 5,078 |
77 | // 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
| uint256 _value; // default: 0
| 7,667 |
4 | // reservedAmount Number of Hashes reserved. | uint256 public reservedAmount;
| uint256 public reservedAmount;
| 23,742 |
10 | // Kernel Interface for Testing | contract TestKernel is KernelInstance {
constructor(address initProcAddress) KernelInstance(initProcAddress) public {
// This is an example kernel global variable for testing.
assembly {
sstore(0x8000,3)
}
}
function testGetter() public view returns(uint256) {
assembly {
mstore(0,sload(0x8000))
return(0,0x20)
}
}
function anyTestGetter(uint256 addr) public view returns(uint256) {
assembly {
mstore(0,sload(addr))
return(0,0x20)
}
}
function testSetter(uint256 value) public {
assembly {
sstore(0x8000,value)
}
}
function setEntryProcedure(bytes24 key) public {
_setEntryProcedure(key);
}
// Create a validated procedure.
function registerProcedure(bytes24 name, address procedureAddress, uint256[] caps) public returns (uint8 err, address retAddress) {
return _registerProcedure(name, procedureAddress, caps);
}
// Create a procedure without going through any validation.
function registerAnyProcedure(bytes24 name, address procedureAddress, uint256[] caps) public returns (uint8 err, address retAddress) {
return _registerAnyProcedure(name, procedureAddress, caps);
}
function deleteProcedure(bytes24 name) public returns (uint8 err, address procedureAddress) {
return _deleteProcedure(name);
}
function executeProcedure(bytes24 name, string fselector, bytes payload) public returns (uint8) {
bytes memory result = _executeProcedure(name, fselector, payload);
return uint8(result[0]);
}
}
| contract TestKernel is KernelInstance {
constructor(address initProcAddress) KernelInstance(initProcAddress) public {
// This is an example kernel global variable for testing.
assembly {
sstore(0x8000,3)
}
}
function testGetter() public view returns(uint256) {
assembly {
mstore(0,sload(0x8000))
return(0,0x20)
}
}
function anyTestGetter(uint256 addr) public view returns(uint256) {
assembly {
mstore(0,sload(addr))
return(0,0x20)
}
}
function testSetter(uint256 value) public {
assembly {
sstore(0x8000,value)
}
}
function setEntryProcedure(bytes24 key) public {
_setEntryProcedure(key);
}
// Create a validated procedure.
function registerProcedure(bytes24 name, address procedureAddress, uint256[] caps) public returns (uint8 err, address retAddress) {
return _registerProcedure(name, procedureAddress, caps);
}
// Create a procedure without going through any validation.
function registerAnyProcedure(bytes24 name, address procedureAddress, uint256[] caps) public returns (uint8 err, address retAddress) {
return _registerAnyProcedure(name, procedureAddress, caps);
}
function deleteProcedure(bytes24 name) public returns (uint8 err, address procedureAddress) {
return _deleteProcedure(name);
}
function executeProcedure(bytes24 name, string fselector, bytes payload) public returns (uint8) {
bytes memory result = _executeProcedure(name, fselector, payload);
return uint8(result[0]);
}
}
| 31,208 |
276 | // check if the caller (of this caller of this) is an aliased L1 contract addressreturn true iff the caller's address is an alias for an L1 contract address / | function wasMyCallersAddressAliased() external view returns (bool);
| function wasMyCallersAddressAliased() external view returns (bool);
| 11,391 |
45 | // total volume tokens per data contracts | mapping(address => uint256) private _totalVolumeToken;
event onWithdrawUserBonus(address indexed userAddress, uint256 ethWithdrawn);
| mapping(address => uint256) private _totalVolumeToken;
event onWithdrawUserBonus(address indexed userAddress, uint256 ethWithdrawn);
| 41,093 |
93 | // import "https:github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/SafeERC20.sol"; | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(
address(this).balance >= amount,
"Address: insufficient balance"
);
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{value: amount}("");
require(
success,
"Address: unable to send value, recipient may have reverted"
);
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data)
internal
returns (bytes memory)
{
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return
functionCallWithValue(
target,
data,
value,
"Address: low-level call with value failed"
);
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(
address(this).balance >= value,
"Address: insufficient balance for call"
);
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) =
target.call{value: value}(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data)
internal
view
returns (bytes memory)
{
return
functionStaticCall(
target,
data,
"Address: low-level static call failed"
);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.3._
*/
function functionDelegateCall(address target, bytes memory data)
internal
returns (bytes memory)
{
return
functionDelegateCall(
target,
data,
"Address: low-level delegate call failed"
);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.3._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.delegatecall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) private pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
| library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(
address(this).balance >= amount,
"Address: insufficient balance"
);
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{value: amount}("");
require(
success,
"Address: unable to send value, recipient may have reverted"
);
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data)
internal
returns (bytes memory)
{
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return
functionCallWithValue(
target,
data,
value,
"Address: low-level call with value failed"
);
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(
address(this).balance >= value,
"Address: insufficient balance for call"
);
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) =
target.call{value: value}(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data)
internal
view
returns (bytes memory)
{
return
functionStaticCall(
target,
data,
"Address: low-level static call failed"
);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.3._
*/
function functionDelegateCall(address target, bytes memory data)
internal
returns (bytes memory)
{
return
functionDelegateCall(
target,
data,
"Address: low-level delegate call failed"
);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.3._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.delegatecall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) private pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
| 2,055 |
419 | // "destroy" the temporary swap fee (like _initialTokens above) in case a subclass tries to use it | _initialSwapFee = 0;
| _initialSwapFee = 0;
| 16,271 |
61 | // Lock two users (suspect and accuser) Note: accuser and suspect cannot already be locked, but this might have to change so a single accuser isn't overwhelmed with fraud | function lock(address suspect) external payable not_locked(msg.sender) not_locked(suspect) {
address accuser = msg.sender;
// Lock both the accuser and the suspect
lockers[suspect] = accuser;
locked_timestamps[suspect] = block.timestamp;
lockers[accuser] = accuser;
locked_timestamps[accuser] = block.timestamp;
// The accuser may be trying to bond at the same time (this also check that have enough bonded)
require(apply_bond(accuser) == 0, "INVALID_BOND");
emit ORI_Locked(suspect, accuser);
}
| function lock(address suspect) external payable not_locked(msg.sender) not_locked(suspect) {
address accuser = msg.sender;
// Lock both the accuser and the suspect
lockers[suspect] = accuser;
locked_timestamps[suspect] = block.timestamp;
lockers[accuser] = accuser;
locked_timestamps[accuser] = block.timestamp;
// The accuser may be trying to bond at the same time (this also check that have enough bonded)
require(apply_bond(accuser) == 0, "INVALID_BOND");
emit ORI_Locked(suspect, accuser);
}
| 45,582 |
8 | // Initialize swapStorage struct | swapStorage.lpToken = new LPToken(
lpTokenName,
lpTokenSymbol,
SwapUtils.POOL_PRECISION_DECIMALS
);
swapStorage.pooledTokens = _pooledTokens;
swapStorage.tokenPrecisionMultipliers = precisionMultipliers;
swapStorage.balances = new uint256[](_pooledTokens.length);
swapStorage.initialA = _a.mul(SwapUtils.A_PRECISION);
swapStorage.futureA = _a.mul(SwapUtils.A_PRECISION);
| swapStorage.lpToken = new LPToken(
lpTokenName,
lpTokenSymbol,
SwapUtils.POOL_PRECISION_DECIMALS
);
swapStorage.pooledTokens = _pooledTokens;
swapStorage.tokenPrecisionMultipliers = precisionMultipliers;
swapStorage.balances = new uint256[](_pooledTokens.length);
swapStorage.initialA = _a.mul(SwapUtils.A_PRECISION);
swapStorage.futureA = _a.mul(SwapUtils.A_PRECISION);
| 36,145 |
15 | // The lower tick of the range | function tickLower() external view returns (int24);
| function tickLower() external view returns (int24);
| 21,556 |
19 | // enforce maximum token supply | require(totalSupply + amount >= totalSupply);
require(totalSupply + amount <= maxSupply);
balances[recipient] += amount;
totalSupply += amount;
Transfer(0, recipient, amount);
| require(totalSupply + amount >= totalSupply);
require(totalSupply + amount <= maxSupply);
balances[recipient] += amount;
totalSupply += amount;
Transfer(0, recipient, amount);
| 62,779 |
77 | // Yields the greatest signed 59.18 decimal fixed-point number less than or equal to x.//Optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional counterparts./ See https:en.wikipedia.org/wiki/Floor_and_ceiling_functions.// Requirements:/ - x must be greater than or equal to MIN_WHOLE_SD59x18.//x The signed 59.18-decimal fixed-point number to floor./result The greatest integer less than or equal to x, as a signed 58.18-decimal fixed-point number. | function floor(int256 x) internal pure returns (int256 result) {
if (x < MIN_WHOLE_SD59x18) {
revert PRBMathSD59x18__FloorUnderflow(x);
}
unchecked {
int256 remainder = x % SCALE;
if (remainder == 0) {
result = x;
} else {
// Solidity uses C fmod style, which returns a modulus with the same sign as x.
result = x - remainder;
if (x < 0) {
result -= SCALE;
}
}
}
}
| function floor(int256 x) internal pure returns (int256 result) {
if (x < MIN_WHOLE_SD59x18) {
revert PRBMathSD59x18__FloorUnderflow(x);
}
unchecked {
int256 remainder = x % SCALE;
if (remainder == 0) {
result = x;
} else {
// Solidity uses C fmod style, which returns a modulus with the same sign as x.
result = x - remainder;
if (x < 0) {
result -= SCALE;
}
}
}
}
| 64,204 |
2 | // As defined in https:eips.ethereum.org/EIPS/eip-777 | interface IERC777 {
event Sent(address indexed operator, address indexed from, address indexed to, uint256 amount, bytes data,
bytes operatorData);
event Minted(address indexed operator, address indexed to, uint256 amount, bytes data, bytes operatorData);
event Burned(address indexed operator, address indexed from, uint256 amount, bytes data, bytes operatorData);
event AuthorizedOperator(address indexed operator,address indexed holder);
event RevokedOperator(address indexed operator, address indexed holder);
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function totalSupply() external view returns (uint256);
function balanceOf(address holder) external view returns (uint256);
function granularity() external view returns (uint256);
function defaultOperators() external view returns (address[] memory);
function isOperatorFor(address operator, address holder) external view returns (bool);
function authorizeOperator(address operator) external;
function revokeOperator(address operator) external;
function send(address to, uint256 amount, bytes calldata data) external;
function operatorSend(address from, address to, uint256 amount, bytes calldata data, bytes calldata operatorData) external;
function burn(uint256 amount, bytes calldata data) external;
function operatorBurn( address from, uint256 amount, bytes calldata data, bytes calldata operatorData) external;
}
| interface IERC777 {
event Sent(address indexed operator, address indexed from, address indexed to, uint256 amount, bytes data,
bytes operatorData);
event Minted(address indexed operator, address indexed to, uint256 amount, bytes data, bytes operatorData);
event Burned(address indexed operator, address indexed from, uint256 amount, bytes data, bytes operatorData);
event AuthorizedOperator(address indexed operator,address indexed holder);
event RevokedOperator(address indexed operator, address indexed holder);
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function totalSupply() external view returns (uint256);
function balanceOf(address holder) external view returns (uint256);
function granularity() external view returns (uint256);
function defaultOperators() external view returns (address[] memory);
function isOperatorFor(address operator, address holder) external view returns (bool);
function authorizeOperator(address operator) external;
function revokeOperator(address operator) external;
function send(address to, uint256 amount, bytes calldata data) external;
function operatorSend(address from, address to, uint256 amount, bytes calldata data, bytes calldata operatorData) external;
function burn(uint256 amount, bytes calldata data) external;
function operatorBurn( address from, uint256 amount, bytes calldata data, bytes calldata operatorData) external;
}
| 39,221 |
74 | // OQUE SOBRAR VAI PARA O FUNDO DE LIQUIDEZ | if(valueDistribute > 0) {
_balances[addressLiquidity()] = _balances[addressLiquidity()].add(valueDistribute);
}
| if(valueDistribute > 0) {
_balances[addressLiquidity()] = _balances[addressLiquidity()].add(valueDistribute);
}
| 19,377 |
70 | // portal Id=> funding round number => true if success of the Aavegotchi portal funding round | mapping(uint256 => mapping(uint256 => bool) internal portalFundingResult;
| mapping(uint256 => mapping(uint256 => bool) internal portalFundingResult;
| 9,551 |
53 | // Claim available UBE rewards | IStakingRewards(farmAddress).getReward();
| IStakingRewards(farmAddress).getReward();
| 14,414 |
140 | // default tax is 8% of every transfer | uint256 taxAmount = amount.mul(transferTaxRate).div(10000);
uint256 burnAmount = taxAmount.mul(burnRate).div(100);
uint256 liquidityAmount = taxAmount.sub(burnAmount);
require(taxAmount == burnAmount + liquidityAmount, "transfer: Burn value invalid");
| uint256 taxAmount = amount.mul(transferTaxRate).div(10000);
uint256 burnAmount = taxAmount.mul(burnRate).div(100);
uint256 liquidityAmount = taxAmount.sub(burnAmount);
require(taxAmount == burnAmount + liquidityAmount, "transfer: Burn value invalid");
| 23,966 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.