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 |
|---|---|---|---|---|
3 | // A struct for storing a snapshot of liquidity accumulations. The difference of a newer snapshot against an older snapshot can be used to derive time-weighted averageliquidities by dividing the difference in value by the difference in time. / | struct LiquidityAccumulator {
/*
* @notice Accumulates time-weighted average liquidity of the token in the form of a sumation of (price * time),
* with time measured in seconds.
* @dev Overflow is desired and results in correct behavior as long as the difference between two snapshots
* is less than or equal to 2^112.
*/
uint112 cumulativeTokenLiquidity;
/*
* @notice Accumulates time-weighted average liquidity of the quote token in the form of a sumation of
* (price * time), with time measured in seconds..
* @dev Overflow is desired and results in correct behavior as long as the difference between two snapshots
* is less than or equal to 2^112.
*/
uint112 cumulativeQuoteTokenLiquidity;
/*
* @notice The unix timestamp (in seconds) of the last update of (addition to) the cumulative price.
*/
uint32 timestamp;
}
| struct LiquidityAccumulator {
/*
* @notice Accumulates time-weighted average liquidity of the token in the form of a sumation of (price * time),
* with time measured in seconds.
* @dev Overflow is desired and results in correct behavior as long as the difference between two snapshots
* is less than or equal to 2^112.
*/
uint112 cumulativeTokenLiquidity;
/*
* @notice Accumulates time-weighted average liquidity of the quote token in the form of a sumation of
* (price * time), with time measured in seconds..
* @dev Overflow is desired and results in correct behavior as long as the difference between two snapshots
* is less than or equal to 2^112.
*/
uint112 cumulativeQuoteTokenLiquidity;
/*
* @notice The unix timestamp (in seconds) of the last update of (addition to) the cumulative price.
*/
uint32 timestamp;
}
| 45,846 |
164 | // Zero-value | require(uints[0] == 0);
| require(uints[0] == 0);
| 23,193 |
19 | // from now there is opponent | bool timeforaction =
(now < bets[MyHash].timestamp + LimitOfMinutes*60) ||
(now < bets[bets[MyHash].OpponentHash].timestamp + LimitOfMinutes*60 );
if(bets[MyHash].Pick == 0 &&
timeforaction
)
return "you can announce your SecretRand";
if(bets[MyHash].Pick == 0)
return "you have failed to announce your SecretRand but still you can try before opponent withdraws";
| bool timeforaction =
(now < bets[MyHash].timestamp + LimitOfMinutes*60) ||
(now < bets[bets[MyHash].OpponentHash].timestamp + LimitOfMinutes*60 );
if(bets[MyHash].Pick == 0 &&
timeforaction
)
return "you can announce your SecretRand";
if(bets[MyHash].Pick == 0)
return "you have failed to announce your SecretRand but still you can try before opponent withdraws";
| 54,830 |
8 | // Generates the calldata to delegate votes to another ETH address. Self and zero address allowed, which is equivalent to registering and revoking in Compoundlike governance systems._delegateeAddress of the delegatee return addressTarget contract addressreturn uint256Total quantity of ETH (Set to 0)return bytesPropose calldata / | function getDelegateCalldata(address _delegatee) external view returns (address, uint256, bytes memory) {
// delegate(address _delegatee)
bytes memory callData = abi.encodeWithSignature(DELEGATE_SIGNATURE, _delegatee);
return (governanceToken, 0, callData);
}
| function getDelegateCalldata(address _delegatee) external view returns (address, uint256, bytes memory) {
// delegate(address _delegatee)
bytes memory callData = abi.encodeWithSignature(DELEGATE_SIGNATURE, _delegatee);
return (governanceToken, 0, callData);
}
| 29,753 |
48 | // This event MUST emit when an address withdraws their dividend./to The address which withdraws ether from this contract./weiAmount The amount of withdrawn ether in wei. | event DividendWithdrawn(
address indexed to,
uint256 weiAmount
);
| event DividendWithdrawn(
address indexed to,
uint256 weiAmount
);
| 16,482 |
12 | // Merchant identifier hash | bytes32 public merchantIdHash;
| bytes32 public merchantIdHash;
| 25,699 |
210 | // Emitted by {_snapshot} when a snapshot identified by `id` is created. / | event Snapshot(uint256 id);
| event Snapshot(uint256 id);
| 3,061 |
68 | // Returns asset implementation contract for current caller. return asset implementation contract. / | function _getAsset() internal view returns (ATxAssetInterface) {
return ATxAssetInterface(getLatestVersion());
}
| function _getAsset() internal view returns (ATxAssetInterface) {
return ATxAssetInterface(getLatestVersion());
}
| 575 |
4 | // Maps a token ID to a Memo. | mapping (uint256 => Memo) public memoForToken;
| mapping (uint256 => Memo) public memoForToken;
| 881 |
145 | // See if there's enough collateral to add to the SAFE in order to save it | if (collateralTokenNeeded <= collateralFromLP) {
return (sysCoinsFromLP, collateralTokenNeeded);
} else {
| if (collateralTokenNeeded <= collateralFromLP) {
return (sysCoinsFromLP, collateralTokenNeeded);
} else {
| 2,452 |
104 | // Cannot recover the staking token or the rewards token | require(
tokenAddress != address(stakingToken) && tokenAddress != address(rewardsToken) && !isCorrectToken,
"Cannot withdraw the staking or rewards tokens"
);
IERC20(tokenAddress).safeTransfer(owner, tokenAmount);
emit Recovered(tokenAddress, tokenAmount);
| require(
tokenAddress != address(stakingToken) && tokenAddress != address(rewardsToken) && !isCorrectToken,
"Cannot withdraw the staking or rewards tokens"
);
IERC20(tokenAddress).safeTransfer(owner, tokenAmount);
emit Recovered(tokenAddress, tokenAmount);
| 5,263 |
54 | // View function to see pending Token/_pid The index of the pool. See `poolInfo`./_user Address of user./ return pending SUSHI reward for a given user. | function pendingToken(uint256 _pid, address _user) public view returns (uint256 pending) {
PoolInfo memory pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accToken1PerShare = pool.accToken1PerShare;
uint256 lpSupply = IMasterChefV2(MASTERCHEF_V2).lpToken(_pid).balanceOf(MASTERCHEF_V2);
if (block.timestamp > pool.lastRewardTime && lpSupply != 0) {
uint256 time = block.timestamp.sub(pool.lastRewardTime);
uint256 sushiReward = time.mul(rewardPerSecond);
accToken1PerShare = accToken1PerShare.add(sushiReward.mul(ACC_TOKEN_PRECISION) / lpSupply);
}
pending = (user.amount.mul(accToken1PerShare) / ACC_TOKEN_PRECISION).sub(user.rewardDebt).add(user.unpaidRewards);
}
| function pendingToken(uint256 _pid, address _user) public view returns (uint256 pending) {
PoolInfo memory pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accToken1PerShare = pool.accToken1PerShare;
uint256 lpSupply = IMasterChefV2(MASTERCHEF_V2).lpToken(_pid).balanceOf(MASTERCHEF_V2);
if (block.timestamp > pool.lastRewardTime && lpSupply != 0) {
uint256 time = block.timestamp.sub(pool.lastRewardTime);
uint256 sushiReward = time.mul(rewardPerSecond);
accToken1PerShare = accToken1PerShare.add(sushiReward.mul(ACC_TOKEN_PRECISION) / lpSupply);
}
pending = (user.amount.mul(accToken1PerShare) / ACC_TOKEN_PRECISION).sub(user.rewardDebt).add(user.unpaidRewards);
}
| 25,372 |
39 | // uint _id = getId(_account, _asset, _loaction); | uint _id = getKeyId(_account, _asset, _loaction);
return getPosition(_id);
| uint _id = getKeyId(_account, _asset, _loaction);
return getPosition(_id);
| 48,449 |
16 | // Function to simply retrieve block number This exists mainly for inheriting test contracts to stub this result. / | function getBlockNumber() internal view returns (uint) {
return block.number;
}
| function getBlockNumber() internal view returns (uint) {
return block.number;
}
| 11,739 |
43 | // The end time cannot be less than the start time for a sale | if (newStage.endTime <= newStage.startTime)
revert EndTimeLessThanStartTime();
if (i > 0) {
uint256 previousStageEndTime = stageMap[i - 1].endTime;
| if (newStage.endTime <= newStage.startTime)
revert EndTimeLessThanStartTime();
if (i > 0) {
uint256 previousStageEndTime = stageMap[i - 1].endTime;
| 26,008 |
109 | // Internal function to withdraw ERC721 tokens. to Address the tokens should be sent to. ERC721Address The contract address of the asset. id The ID of the ERC721 token. Used for all tokens type == 1. The function checks whether any other ERC721 is deposited in the Vault.If not, it pops the stored addresses and stored IDs (pop() of two arrays is 180 gas cheaper than deleting).If there are, it loops through the stored arrays and searches the ID that's withdrawn,then replaces it with the last index, followed by a pop(). Sensitive to ReEntrance attacks! SafeTransferFrom therefore done at the end | function _withdrawERC721(address to, address ERC721Address, uint256 id) internal {
uint256 tokenIdLength = erc721TokenIds.length;
uint256 i;
if (tokenIdLength == 1) {
//There was only one ERC721 stored on the contract, safe to remove both lists.
require(erc721TokenIds[0] == id && erc721Stored[0] == ERC721Address, "V_W721: Unknown asset");
erc721TokenIds.pop();
erc721Stored.pop();
} else {
for (i; i < tokenIdLength;) {
if (erc721TokenIds[i] == id && erc721Stored[i] == ERC721Address) {
erc721TokenIds[i] = erc721TokenIds[tokenIdLength - 1];
erc721TokenIds.pop();
erc721Stored[i] = erc721Stored[tokenIdLength - 1];
erc721Stored.pop();
break;
}
unchecked {
++i;
}
}
//For loop should break, otherwise we never went into the if-branch, meaning the token being withdrawn
//is unknown and not properly deposited.
require(i < tokenIdLength, "V_W721: Unknown asset");
}
IERC721(ERC721Address).safeTransferFrom(address(this), to, id);
}
| function _withdrawERC721(address to, address ERC721Address, uint256 id) internal {
uint256 tokenIdLength = erc721TokenIds.length;
uint256 i;
if (tokenIdLength == 1) {
//There was only one ERC721 stored on the contract, safe to remove both lists.
require(erc721TokenIds[0] == id && erc721Stored[0] == ERC721Address, "V_W721: Unknown asset");
erc721TokenIds.pop();
erc721Stored.pop();
} else {
for (i; i < tokenIdLength;) {
if (erc721TokenIds[i] == id && erc721Stored[i] == ERC721Address) {
erc721TokenIds[i] = erc721TokenIds[tokenIdLength - 1];
erc721TokenIds.pop();
erc721Stored[i] = erc721Stored[tokenIdLength - 1];
erc721Stored.pop();
break;
}
unchecked {
++i;
}
}
//For loop should break, otherwise we never went into the if-branch, meaning the token being withdrawn
//is unknown and not properly deposited.
require(i < tokenIdLength, "V_W721: Unknown asset");
}
IERC721(ERC721Address).safeTransferFrom(address(this), to, id);
}
| 15,119 |
3 | // Struct to track Token template. | struct Token {
bool exists;
uint256 templateId;
uint256 index;
}
| struct Token {
bool exists;
uint256 templateId;
uint256 index;
}
| 4,502 |
209 | // Use a simple bonding curve. Increase 20% every 8 sold. Only use this curve on genesis. Alpha price will start from last genesis price | if(totalSoldCounter < 512) {
if (totalSoldCounter % 8 == 0) {
stnBkPremiumPrice += stnBkPremiumPrice / 20;
}
| if(totalSoldCounter < 512) {
if (totalSoldCounter % 8 == 0) {
stnBkPremiumPrice += stnBkPremiumPrice / 20;
}
| 49,441 |
12 | // We run that for loop because the only way to delete an item in an array is to pop its last index so we organize the items accordingly | for (uint i = index; i<exchanges.length-1; i++){
exchanges[i] = exchanges[i+1];
}
| for (uint i = index; i<exchanges.length-1; i++){
exchanges[i] = exchanges[i+1];
}
| 22,426 |
0 | // calcSpotPricesP = spotPrice bI = tokenBalanceIn( bI / wI ) 1 bO = tokenBalanceOut sP =---------------------wI = tokenWeightIn ( bO / wO ) ( 1 - sF )wO = tokenWeightOutsF = swapFee/ | {
uint numer = bdiv(tokenBalanceIn, tokenWeightIn);
uint denom = bdiv(tokenBalanceOut, tokenWeightOut);
uint ratio = bdiv(numer, denom);
uint scale = bdiv(BONE, bsub(BONE, swapFee));
return (spotPrice = bmul(ratio, scale));
}
| {
uint numer = bdiv(tokenBalanceIn, tokenWeightIn);
uint denom = bdiv(tokenBalanceOut, tokenWeightOut);
uint ratio = bdiv(numer, denom);
uint scale = bdiv(BONE, bsub(BONE, swapFee));
return (spotPrice = bmul(ratio, scale));
}
| 33,871 |
0 | // Creates a request that can hold additional parameters _specId The Job Specification ID that the request will be created for _callbackAddress The callback address that the response will be sent to _callbackFunctionSignature The callback function signature to use for the callback addressreturn A Plugin Request struct in memory / | function buildPluginRequest(
bytes32 _specId,
address _callbackAddress,
bytes4 _callbackFunctionSignature
) internal pure returns (Plugin.Request memory) {
Plugin.Request memory req;
return req.initialize(_specId, _callbackAddress, _callbackFunctionSignature);
}
| function buildPluginRequest(
bytes32 _specId,
address _callbackAddress,
bytes4 _callbackFunctionSignature
) internal pure returns (Plugin.Request memory) {
Plugin.Request memory req;
return req.initialize(_specId, _callbackAddress, _callbackFunctionSignature);
}
| 28,817 |
3 | // 操作数组存取 查询数据库 | function getData(uint n)public view returns(uint,string){
return (stringData.length,stringData[i]);
}
| function getData(uint n)public view returns(uint,string){
return (stringData.length,stringData[i]);
}
| 11,765 |
4 | // Returns true if and only if the function is running in the constructor | function isConstructor() private view returns (bool) {
// extcodesize checks the size of the code stored in an address, and
// address returns the current address. Since the code is still not
// deployed when running a constructor, any checks on its code size will
// yield zero, making it an effective way to detect if a contract is
// under construction or not.
address self = address(this);
uint256 cs;
assembly { cs := extcodesize(self) }
return cs == 0;
}
| function isConstructor() private view returns (bool) {
// extcodesize checks the size of the code stored in an address, and
// address returns the current address. Since the code is still not
// deployed when running a constructor, any checks on its code size will
// yield zero, making it an effective way to detect if a contract is
// under construction or not.
address self = address(this);
uint256 cs;
assembly { cs := extcodesize(self) }
return cs == 0;
}
| 6,016 |
1 | // Migrates pools which pids are given in array(pools). Can be called one time, when eTacoChef poolInfo is empty. oldPools Array which contains old master pids that must be migrated. newPools Array which contains new master pids that must be migrated. / | function migratePools(uint256[] memory oldPools, uint256[] memory newPools) external onlyOwner {
uint256 poolsLength = oldPools.length;
for (uint256 i = 0; i < poolsLength; i++) {
(address lpToken, uint256 allocPoint, uint256 lastRewardBlock, uint256 accTacoPerShare) =
oldChef.poolInfo(oldPools[i]);
ITacoswapV2Pair lp = ITacoswapV2Pair(lpToken);
DummyToken dummyToken = new DummyToken();
dummyToken.mint(address(newChef), lp.balanceOf(address(oldChef)));
dummyToken.mint(msg.sender, 1e21);
lpTokenToDummyToken[lpToken] = address(dummyToken);
newChef.setPool(
newPools[i],
address(dummyToken),
allocPoint,
lastRewardBlock,
accTacoPerShare
);
}
}
| function migratePools(uint256[] memory oldPools, uint256[] memory newPools) external onlyOwner {
uint256 poolsLength = oldPools.length;
for (uint256 i = 0; i < poolsLength; i++) {
(address lpToken, uint256 allocPoint, uint256 lastRewardBlock, uint256 accTacoPerShare) =
oldChef.poolInfo(oldPools[i]);
ITacoswapV2Pair lp = ITacoswapV2Pair(lpToken);
DummyToken dummyToken = new DummyToken();
dummyToken.mint(address(newChef), lp.balanceOf(address(oldChef)));
dummyToken.mint(msg.sender, 1e21);
lpTokenToDummyToken[lpToken] = address(dummyToken);
newChef.setPool(
newPools[i],
address(dummyToken),
allocPoint,
lastRewardBlock,
accTacoPerShare
);
}
}
| 46,165 |
205 | // found | return mid;
| return mid;
| 31,500 |
10 | // ADMIN FUNCTIONS/ | {
_setupRole(AUTHORIZED_CALLER, adr);
}
| {
_setupRole(AUTHORIZED_CALLER, adr);
}
| 15,543 |
2 | // Require nym to be present, and fit into one data slot | if (attributes[0][0] != 1) {
ValidationError(NYM, "must be present");
return false;
}
| if (attributes[0][0] != 1) {
ValidationError(NYM, "must be present");
return false;
}
| 23,065 |
1 | // mapping(bytes32 => bytes[]) internal bytesArrayStorage; | mapping(bytes32 => bool[]) internal boolArrayStorage;
mapping(bytes32 => int256[]) internal intArrayStorage;
mapping(bytes32 => bytes32[]) internal bytes32ArrayStorage;
| mapping(bytes32 => bool[]) internal boolArrayStorage;
mapping(bytes32 => int256[]) internal intArrayStorage;
mapping(bytes32 => bytes32[]) internal bytes32ArrayStorage;
| 47,377 |
19 | // ------------------------------------------------------------------------ Token owner can approve for `spender` to transferFrom(...) `tokens` from the token owner's account ------------------------------------------------------------------------ | function approve(address spender, uint256 tokens) public override returns (bool success){
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender,spender,tokens);
return true;
}
| function approve(address spender, uint256 tokens) public override returns (bool success){
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender,spender,tokens);
return true;
}
| 9,221 |
14 | // Structs // State Valiables // Events / Triggered when tokens are transferred. | event Transfer(
address indexed _from,
address indexed _to,
uint256 _value);
| event Transfer(
address indexed _from,
address indexed _to,
uint256 _value);
| 8,470 |
160 | // divides bytes signature into `uint8 v, bytes32 r, bytes32 s`./Make sure to peform a bounds check forpos, to avoid out of bounds access onsignatures/pos which signature to read. A prior bounds check of this parameter should be performed, to avoid out of bounds access/signatures concatenated rsv signatures | function signatureSplit(bytes memory signatures, uint256 pos)
internal
pure
returns (
uint8 v,
bytes32 r,
bytes32 s
)
| function signatureSplit(bytes memory signatures, uint256 pos)
internal
pure
returns (
uint8 v,
bytes32 r,
bytes32 s
)
| 58,145 |
5 | // a way to cheaply extract more results from a seed without re-rolling it example: (seed, 10000, 100, 25) skips last two digits of seed and gets a 0-24 from from the new end WARNING: distribution of results may not be even! For even distribution use whole multiples of mod for the number of decimals at work (ie 2 digits with mod 4) | return seed.mod(slice).div(div).mod(mod);
| return seed.mod(slice).div(div).mod(mod);
| 26,637 |
191 | // amount = (ethValuedecimals) / tokenEthPrice | return ((10**decimals).mul(ethValue)).div(tokenEthPrice); //tokenAmount
| return ((10**decimals).mul(ethValue)).div(tokenEthPrice); //tokenAmount
| 3,107 |
29 | // -------------------- Verification functions : ---------------------- / from user acc (!) Gas requirement: infinite | function uploadSignedString(string _fingerprint, bytes20 _fingerprintBytes20, string _signedString) public payable {
// check length of the uploaded string,
// it expected to be a 64 chars string signed with OpenPGP standard signature
// bytes: Dynamically-sized byte array,
// see: http://solidity.readthedocs.io/en/develop/types.html#dynamically-sized-byte-array
// if (bytes(_signedString).length > 1000) {//
// revert();
// // (payable)
// }
// --- not needed: if string is to big -> out of gas
// check payment :
if (msg.value < priceForVerificationInWei) {
revert();
// (payable)
}
// if signed string already uploaded, should revert
if (signedStringUploadedOnUnixTime[msg.sender] != 0) {
revert();
// (payable)
}
// fingerprint should be uppercase 40 symbols
if (bytes(_fingerprint).length != 40) {
revert();
// (payable)
}
// fingerprint can be connected to one eth address only
if (addressAttached[_fingerprintBytes20] != 0) {
revert();
// (payable)
}
// at this stage we can not be sure that key with this fingerprint really owned by user
// thus we store it as 'unverified'
unverifiedFingerprint[msg.sender] = _fingerprint;
signedString[msg.sender] = verification[msg.sender].signedString = _signedString;
// uint256 - Unix Time
signedStringUploadedOnUnixTime[msg.sender] = block.timestamp;
SignedStringUploaded(msg.sender, _fingerprint, _signedString);
}
| function uploadSignedString(string _fingerprint, bytes20 _fingerprintBytes20, string _signedString) public payable {
// check length of the uploaded string,
// it expected to be a 64 chars string signed with OpenPGP standard signature
// bytes: Dynamically-sized byte array,
// see: http://solidity.readthedocs.io/en/develop/types.html#dynamically-sized-byte-array
// if (bytes(_signedString).length > 1000) {//
// revert();
// // (payable)
// }
// --- not needed: if string is to big -> out of gas
// check payment :
if (msg.value < priceForVerificationInWei) {
revert();
// (payable)
}
// if signed string already uploaded, should revert
if (signedStringUploadedOnUnixTime[msg.sender] != 0) {
revert();
// (payable)
}
// fingerprint should be uppercase 40 symbols
if (bytes(_fingerprint).length != 40) {
revert();
// (payable)
}
// fingerprint can be connected to one eth address only
if (addressAttached[_fingerprintBytes20] != 0) {
revert();
// (payable)
}
// at this stage we can not be sure that key with this fingerprint really owned by user
// thus we store it as 'unverified'
unverifiedFingerprint[msg.sender] = _fingerprint;
signedString[msg.sender] = verification[msg.sender].signedString = _signedString;
// uint256 - Unix Time
signedStringUploadedOnUnixTime[msg.sender] = block.timestamp;
SignedStringUploaded(msg.sender, _fingerprint, _signedString);
}
| 18,023 |
11 | // Then fill in request details | if (_paysValue > 0) {
_req.paysValue = _paysValue;
}
| if (_paysValue > 0) {
_req.paysValue = _paysValue;
}
| 24,076 |
57 | // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature unique. Appendix F in the Ethereum Yellow paper (https:ethereum.github.io/yellowpaper/paper.pdf), defines the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most signatures from current libraries generate a unique signature with an s-value in the lower half order. If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or vice versa. If your library | if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
| if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
| 414 |
5 | // Event emitted when a liquidity mining incentive has been created/rewardToken The token being distributed as a reward/bonusRewardToken The token being distributed as a bonus reward/pool The Algebra pool/startTime The time when the incentive program begins/endTime The time when rewards stop accruing/reward The amount of reward tokens to be distributed/bonusReward The amount of bonus reward tokens to be distributed/tiers The amounts of locked token for liquidity multipliers/multiplierToken The address of token which can be locked to get liquidity multiplier/minimalAllowedPositionWidth The minimal allowed position width (tickUpper - tickLower)/enterStartTime The time when enter becomes possible | event LimitFarmingCreated(
IERC20Minimal indexed rewardToken,
IERC20Minimal indexed bonusRewardToken,
IAlgebraPool indexed pool,
uint256 startTime,
uint256 endTime,
uint256 reward,
uint256 bonusReward,
Tiers tiers,
address multiplierToken,
| event LimitFarmingCreated(
IERC20Minimal indexed rewardToken,
IERC20Minimal indexed bonusRewardToken,
IAlgebraPool indexed pool,
uint256 startTime,
uint256 endTime,
uint256 reward,
uint256 bonusReward,
Tiers tiers,
address multiplierToken,
| 14,020 |
25 | // Implement template method of BaseAccount. Uses a modified version of `SignatureChecker.isValidSignatureNow` inwhich the digest is wrapped with an "Ethereum Signed Message" envelopefor the EOA-owner case but not in the ERC-1271 contract-owner case. / | function _validateSignature(UserOperation calldata userOp, bytes32 userOpHash)
internal
virtual
override
returns (uint256 validationData)
| function _validateSignature(UserOperation calldata userOp, bytes32 userOpHash)
internal
virtual
override
returns (uint256 validationData)
| 18,712 |
200 | // Release funds to the factory/_token The ERC20 to transfer/_amount The amount to transfer | function withdraw(IERC20 _token, uint256 _amount) external onlyFactory {
SafeERC20.safeTransfer(_token, msg.sender, _amount);
}
| function withdraw(IERC20 _token, uint256 _amount) external onlyFactory {
SafeERC20.safeTransfer(_token, msg.sender, _amount);
}
| 60,289 |
74 | // interest amounts accrued | uint accruedInterest;
| uint accruedInterest;
| 9,351 |
5 | // Increment it so next time it's correct when we call .current() | _tokenIdCounter.increment();
| _tokenIdCounter.increment();
| 407 |
416 | // you can't set per token royalties if using "contract wide" ones | require(
!_useContractRoyalties,
'!ERC2981Royalties:ROYALTIES_CONTRACT_WIDE!'
);
require(value <= 10000, '!ERC2981Royalties:TOO_HIGH!');
_royalties[id] = RoyaltyData(recipient, uint96(value));
| require(
!_useContractRoyalties,
'!ERC2981Royalties:ROYALTIES_CONTRACT_WIDE!'
);
require(value <= 10000, '!ERC2981Royalties:TOO_HIGH!');
_royalties[id] = RoyaltyData(recipient, uint96(value));
| 75,236 |
80 | // Transfer `amount` of token `token` to `smartWallet`, providing theinitial user signing key `initialUserSigningKey` as proof that thespecified smart wallet is indeed a Dharma Smart Wallet - this assumes thatthe address is derived and deployed using the Dharma Smart Wallet FactoryV1. Only the owner or the designated deposit manager role may call thisfunction. smartWallet address The smart wallet to transfer tokens to. initialUserSigningKey address The initial user signing key suppliedwhen deriving the smart wallet address - this could be an EOA or a Dharmakey ring address. token ERC20Interface The token to transfer. amount uint256 The amount of tokens to transfer. / | function finalizeTokenDeposit(
address smartWallet,
address initialUserSigningKey,
ERC20Interface token,
uint256 amount
| function finalizeTokenDeposit(
address smartWallet,
address initialUserSigningKey,
ERC20Interface token,
uint256 amount
| 35,652 |
10 | // these storage values are unknown but fixed | uint256 value;
uint256 data;
uint256 count;
function checkSignatures(
GnosisSafe gnosis, Executor executor, // to avoid multiple instances
uint256 signatures
)
public
| uint256 value;
uint256 data;
uint256 count;
function checkSignatures(
GnosisSafe gnosis, Executor executor, // to avoid multiple instances
uint256 signatures
)
public
| 51,074 |
6 | // Get the weight of the current voter based on number of tokens they own | uint weight = balances[msg.sender];
| uint weight = balances[msg.sender];
| 56,554 |
272 | // Similar to the rawCollateral in PositionData, this value should not be used directly. _getFeeAdjustedCollateral(), _addCollateral() and _removeCollateral() must be used to access and adjust. | FixedPoint.Unsigned public rawTotalPositionCollateral;
| FixedPoint.Unsigned public rawTotalPositionCollateral;
| 34,831 |
15 | // Caller deposits the staking token to start earning rewards _amount amount of staking token to deposit / | function deposit(uint256 _amount)
external
override
notStopped
nonReentrant
| function deposit(uint256 _amount)
external
override
notStopped
nonReentrant
| 48,070 |
5 | // Emitted when issuance SupplyThrottle params are set | event IssuanceThrottleSet(ThrottleLib.Params oldVal, ThrottleLib.Params newVal);
| event IssuanceThrottleSet(ThrottleLib.Params oldVal, ThrottleLib.Params newVal);
| 4,683 |
79 | // List of all tokens | Token[] tokens;
| Token[] tokens;
| 80,926 |
81 | // Liquidity zap into CHEF. | function zapToMasterChef(
address to,
address _FromTokenContractAddress,
uint256 _amount,
uint256 _minPoolTokens,
uint256 pid,
address _swapTarget,
bytes calldata swapData
| function zapToMasterChef(
address to,
address _FromTokenContractAddress,
uint256 _amount,
uint256 _minPoolTokens,
uint256 pid,
address _swapTarget,
bytes calldata swapData
| 18,673 |
12 | // 玄武 奖池 40%, 所有持KEY玩家 -40%, 推荐 - 10%, 开发团队 - 5%, 空投 - 5% | fees_[3] = F3Ddatasets.TeamFee(40,0);
| fees_[3] = F3Ddatasets.TeamFee(40,0);
| 14,936 |
121 | // For purchase with NUX token only. Available only for tokensale nuxAmount Amount of the NUX token / | function purchaseDHVwithNUX(uint256 nuxAmount) external onlyPreSale whenNotPaused correctGas {
require(nuxAmount > 0, "Zero amount");
uint256 purchaseAmount = _calcPurchaseAmount(NUXToken, nuxAmount);
require(purchaseAmount.add(purchased[msg.sender]) <= maxTokensAmount, "Maximum allowed exceeded");
require(purchasedWithNUX.add(purchaseAmount) <= PRE_SALE_DHV_NUX_POOL, "Not enough DHV in NUX pool");
purchasedWithNUX = purchasedWithNUX.add(purchaseAmount);
purchased[_msgSender()] = purchased[_msgSender()].add(purchaseAmount);
IERC20Upgradeable(NUXToken).safeTransferFrom(_msgSender(), _treasury, nuxAmount);
emit DHVPurchased(_msgSender(), NUXToken, purchaseAmount);
}
| function purchaseDHVwithNUX(uint256 nuxAmount) external onlyPreSale whenNotPaused correctGas {
require(nuxAmount > 0, "Zero amount");
uint256 purchaseAmount = _calcPurchaseAmount(NUXToken, nuxAmount);
require(purchaseAmount.add(purchased[msg.sender]) <= maxTokensAmount, "Maximum allowed exceeded");
require(purchasedWithNUX.add(purchaseAmount) <= PRE_SALE_DHV_NUX_POOL, "Not enough DHV in NUX pool");
purchasedWithNUX = purchasedWithNUX.add(purchaseAmount);
purchased[_msgSender()] = purchased[_msgSender()].add(purchaseAmount);
IERC20Upgradeable(NUXToken).safeTransferFrom(_msgSender(), _treasury, nuxAmount);
emit DHVPurchased(_msgSender(), NUXToken, purchaseAmount);
}
| 37,762 |
4 | // A mapping of the number of Collection minted per collectionId per user assetMintedPerCollectionId[msg.sender][collectionId] => number of minted Asset | mapping(address => mapping(uint256 => uint256))
private assetMintedPerCollectionId;
| mapping(address => mapping(uint256 => uint256))
private assetMintedPerCollectionId;
| 66,373 |
6 | // computes e ^ (x / FIXED_1)FIXED_1 input range: 0 <= x <= OPT_EXP_MAX_VAL - 1 auto-generated via 'PrintFunctionOptimalExp.py' Detailed description: - Rewrite the input as a sum of binary exponents and a single residual r, as small as possible - The exponentiation of each binary exponent is given (pre-calculated) - The exponentiation of r is calculated via Taylor series for e^x, where x = r - The exponentiation of the input is calculated by multiplying the intermediate results above - For example: e^5.521692859 = e^(4 + 1 + 0.5 + 0.021692859) = e^4e^1e^0.5e^0.021692859/ | function optimalExp(uint256 x) public pure returns (uint256) {
uint256 res = 0;
uint256 y;
uint256 z;
z = y = x % 0x10000000000000000000000000000000; // get the input modulo 2^(-3)
z = (z * y) / FIXED_1;
res += z * 0x10e1b3be415a0000; // add y^02 * (20! / 02!)
z = (z * y) / FIXED_1;
res += z * 0x05a0913f6b1e0000; // add y^03 * (20! / 03!)
z = (z * y) / FIXED_1;
res += z * 0x0168244fdac78000; // add y^04 * (20! / 04!)
z = (z * y) / FIXED_1;
res += z * 0x004807432bc18000; // add y^05 * (20! / 05!)
z = (z * y) / FIXED_1;
res += z * 0x000c0135dca04000; // add y^06 * (20! / 06!)
z = (z * y) / FIXED_1;
res += z * 0x0001b707b1cdc000; // add y^07 * (20! / 07!)
z = (z * y) / FIXED_1;
res += z * 0x000036e0f639b800; // add y^08 * (20! / 08!)
z = (z * y) / FIXED_1;
res += z * 0x00000618fee9f800; // add y^09 * (20! / 09!)
z = (z * y) / FIXED_1;
res += z * 0x0000009c197dcc00; // add y^10 * (20! / 10!)
z = (z * y) / FIXED_1;
res += z * 0x0000000e30dce400; // add y^11 * (20! / 11!)
z = (z * y) / FIXED_1;
res += z * 0x000000012ebd1300; // add y^12 * (20! / 12!)
z = (z * y) / FIXED_1;
res += z * 0x0000000017499f00; // add y^13 * (20! / 13!)
z = (z * y) / FIXED_1;
res += z * 0x0000000001a9d480; // add y^14 * (20! / 14!)
z = (z * y) / FIXED_1;
res += z * 0x00000000001c6380; // add y^15 * (20! / 15!)
z = (z * y) / FIXED_1;
res += z * 0x000000000001c638; // add y^16 * (20! / 16!)
z = (z * y) / FIXED_1;
res += z * 0x0000000000001ab8; // add y^17 * (20! / 17!)
z = (z * y) / FIXED_1;
res += z * 0x000000000000017c; // add y^18 * (20! / 18!)
z = (z * y) / FIXED_1;
res += z * 0x0000000000000014; // add y^19 * (20! / 19!)
z = (z * y) / FIXED_1;
res += z * 0x0000000000000001; // add y^20 * (20! / 20!)
res = res / 0x21c3677c82b40000 + y + FIXED_1; // divide by 20! and then add y^1 / 1! + y^0 / 0!
if ((x & 0x010000000000000000000000000000000) != 0)
res = (res * 0x1c3d6a24ed82218787d624d3e5eba95f9) / 0x18ebef9eac820ae8682b9793ac6d1e776; // multiply by e^2^(-3)
if ((x & 0x020000000000000000000000000000000) != 0)
res = (res * 0x18ebef9eac820ae8682b9793ac6d1e778) / 0x1368b2fc6f9609fe7aceb46aa619baed4; // multiply by e^2^(-2)
if ((x & 0x040000000000000000000000000000000) != 0)
res = (res * 0x1368b2fc6f9609fe7aceb46aa619baed5) / 0x0bc5ab1b16779be3575bd8f0520a9f21f; // multiply by e^2^(-1)
if ((x & 0x080000000000000000000000000000000) != 0)
res = (res * 0x0bc5ab1b16779be3575bd8f0520a9f21e) / 0x0454aaa8efe072e7f6ddbab84b40a55c9; // multiply by e^2^(+0)
if ((x & 0x100000000000000000000000000000000) != 0)
res = (res * 0x0454aaa8efe072e7f6ddbab84b40a55c5) / 0x00960aadc109e7a3bf4578099615711ea; // multiply by e^2^(+1)
if ((x & 0x200000000000000000000000000000000) != 0)
res = (res * 0x00960aadc109e7a3bf4578099615711d7) / 0x0002bf84208204f5977f9a8cf01fdce3d; // multiply by e^2^(+2)
if ((x & 0x400000000000000000000000000000000) != 0)
res = (res * 0x0002bf84208204f5977f9a8cf01fdc307) / 0x0000003c6ab775dd0b95b4cbee7e65d11; // multiply by e^2^(+3)
return res;
}
| function optimalExp(uint256 x) public pure returns (uint256) {
uint256 res = 0;
uint256 y;
uint256 z;
z = y = x % 0x10000000000000000000000000000000; // get the input modulo 2^(-3)
z = (z * y) / FIXED_1;
res += z * 0x10e1b3be415a0000; // add y^02 * (20! / 02!)
z = (z * y) / FIXED_1;
res += z * 0x05a0913f6b1e0000; // add y^03 * (20! / 03!)
z = (z * y) / FIXED_1;
res += z * 0x0168244fdac78000; // add y^04 * (20! / 04!)
z = (z * y) / FIXED_1;
res += z * 0x004807432bc18000; // add y^05 * (20! / 05!)
z = (z * y) / FIXED_1;
res += z * 0x000c0135dca04000; // add y^06 * (20! / 06!)
z = (z * y) / FIXED_1;
res += z * 0x0001b707b1cdc000; // add y^07 * (20! / 07!)
z = (z * y) / FIXED_1;
res += z * 0x000036e0f639b800; // add y^08 * (20! / 08!)
z = (z * y) / FIXED_1;
res += z * 0x00000618fee9f800; // add y^09 * (20! / 09!)
z = (z * y) / FIXED_1;
res += z * 0x0000009c197dcc00; // add y^10 * (20! / 10!)
z = (z * y) / FIXED_1;
res += z * 0x0000000e30dce400; // add y^11 * (20! / 11!)
z = (z * y) / FIXED_1;
res += z * 0x000000012ebd1300; // add y^12 * (20! / 12!)
z = (z * y) / FIXED_1;
res += z * 0x0000000017499f00; // add y^13 * (20! / 13!)
z = (z * y) / FIXED_1;
res += z * 0x0000000001a9d480; // add y^14 * (20! / 14!)
z = (z * y) / FIXED_1;
res += z * 0x00000000001c6380; // add y^15 * (20! / 15!)
z = (z * y) / FIXED_1;
res += z * 0x000000000001c638; // add y^16 * (20! / 16!)
z = (z * y) / FIXED_1;
res += z * 0x0000000000001ab8; // add y^17 * (20! / 17!)
z = (z * y) / FIXED_1;
res += z * 0x000000000000017c; // add y^18 * (20! / 18!)
z = (z * y) / FIXED_1;
res += z * 0x0000000000000014; // add y^19 * (20! / 19!)
z = (z * y) / FIXED_1;
res += z * 0x0000000000000001; // add y^20 * (20! / 20!)
res = res / 0x21c3677c82b40000 + y + FIXED_1; // divide by 20! and then add y^1 / 1! + y^0 / 0!
if ((x & 0x010000000000000000000000000000000) != 0)
res = (res * 0x1c3d6a24ed82218787d624d3e5eba95f9) / 0x18ebef9eac820ae8682b9793ac6d1e776; // multiply by e^2^(-3)
if ((x & 0x020000000000000000000000000000000) != 0)
res = (res * 0x18ebef9eac820ae8682b9793ac6d1e778) / 0x1368b2fc6f9609fe7aceb46aa619baed4; // multiply by e^2^(-2)
if ((x & 0x040000000000000000000000000000000) != 0)
res = (res * 0x1368b2fc6f9609fe7aceb46aa619baed5) / 0x0bc5ab1b16779be3575bd8f0520a9f21f; // multiply by e^2^(-1)
if ((x & 0x080000000000000000000000000000000) != 0)
res = (res * 0x0bc5ab1b16779be3575bd8f0520a9f21e) / 0x0454aaa8efe072e7f6ddbab84b40a55c9; // multiply by e^2^(+0)
if ((x & 0x100000000000000000000000000000000) != 0)
res = (res * 0x0454aaa8efe072e7f6ddbab84b40a55c5) / 0x00960aadc109e7a3bf4578099615711ea; // multiply by e^2^(+1)
if ((x & 0x200000000000000000000000000000000) != 0)
res = (res * 0x00960aadc109e7a3bf4578099615711d7) / 0x0002bf84208204f5977f9a8cf01fdce3d; // multiply by e^2^(+2)
if ((x & 0x400000000000000000000000000000000) != 0)
res = (res * 0x0002bf84208204f5977f9a8cf01fdc307) / 0x0000003c6ab775dd0b95b4cbee7e65d11; // multiply by e^2^(+3)
return res;
}
| 35,558 |
89 | // we go from 1 to 0 : we swap ether to tether | uint256 wholeEtherBalance = this.getEtherBalance();
this.swap(_maticWEther,_maticTether,wholeEtherBalance,0,address(this));
_cashMode = true;
| uint256 wholeEtherBalance = this.getEtherBalance();
this.swap(_maticWEther,_maticTether,wholeEtherBalance,0,address(this));
_cashMode = true;
| 48,952 |
24 | // For querying balance of a particular account/_owner The address for balance query/Required for ERC-721 compliance. | function balanceOf(address _owner)
public
view
returns (uint balance)
| function balanceOf(address _owner)
public
view
returns (uint balance)
| 23,737 |
23 | // SAFE database | SAFEEngineLike public safeEngine;
| SAFEEngineLike public safeEngine;
| 47,434 |
95 | // cc:III. MintAllowed Setting2;Mint Allowed Switch;1; SETTING: Mint Allowed Switch (bool) Boundary: true or false Enables or disables token minting ability globally (even for custodian). | bool private mintAllowed = false;
| bool private mintAllowed = false;
| 45,087 |
3 | // Call TransferProxy contract to transfer user tokens to Vault | state.transferProxyInstance.transfer(
_token,
_quantity,
msg.sender,
state.vault
);
| state.transferProxyInstance.transfer(
_token,
_quantity,
msg.sender,
state.vault
);
| 18,054 |
5 | // / Validate configWord cleaness for future compatibility, or else may introduce undefined future behavior | function isConfigWordClean(uint256 configWord) internal pure returns (bool) {
return (configWord & ~(APP_LEVEL_MASK | APP_JAIL_BIT | AGREEMENT_CALLBACK_NOOP_BITMASKS)) == uint256(0);
}
| function isConfigWordClean(uint256 configWord) internal pure returns (bool) {
return (configWord & ~(APP_LEVEL_MASK | APP_JAIL_BIT | AGREEMENT_CALLBACK_NOOP_BITMASKS)) == uint256(0);
}
| 16,895 |
6 | // ============================= INITIALIZER ============================= / Set params of nft collection _uri For nft metadata _containerName Plain text representation, 'symbol' on chain _containerLabel Integer value _containerSerial keccak256 hash representing container off-chain _defaultAdmin Default admin address _royaltyWallet Wallet to recieve royalty from 3rd party sale / | function initialize(
string memory _uri,
string memory _containerName,
string memory _containerLabel,
bytes32 _containerSerial,
address _defaultAdmin,
address _royaltyWallet,
address _minter
) external payable {
require(initialized == false, 'Contract already initialized!');
| function initialize(
string memory _uri,
string memory _containerName,
string memory _containerLabel,
bytes32 _containerSerial,
address _defaultAdmin,
address _royaltyWallet,
address _minter
) external payable {
require(initialized == false, 'Contract already initialized!');
| 8,102 |
64 | // only allow admins to execute buy and sell proposals early | return true;
| return true;
| 10,792 |
17 | // Thrown on configurator attempting to add more than 256 collateral tokens | error TooManyTokensException();
| error TooManyTokensException();
| 20,230 |
69 | // exclude owner and this contract from fee. | excludeAccountFromFee(owner());
excludeAccountFromFee(address(this));
| excludeAccountFromFee(owner());
excludeAccountFromFee(address(this));
| 12,956 |
44 | // calculate the expected root based on the proof | bytes32 _calculatedRoot = MerkleLib.branchRoot(_leaf, _proof, _index);
| bytes32 _calculatedRoot = MerkleLib.branchRoot(_leaf, _proof, _index);
| 51,335 |
11 | // Request the description based on the login | Chainlink.Request memory req = buildChainlinkRequest(stringToBytes32(_jobId), address(this), this.fullfillVerification.selector);
req.add("login", _login);
req.add("action", "verify");
| Chainlink.Request memory req = buildChainlinkRequest(stringToBytes32(_jobId), address(this), this.fullfillVerification.selector);
req.add("login", _login);
req.add("action", "verify");
| 4,514 |
33 | // Increase the amount of tokens that an owner allowed to a spender._spender The address which will spend the funds._addedValue The amount of tokens to increase the allowance by./ | function increaseApproval(
address _spender,
uint _addedValue
)
public
returns (bool)
| function increaseApproval(
address _spender,
uint _addedValue
)
public
returns (bool)
| 21,700 |
18 | // only valid before tally | function matchable(address token) private view returns (uint) {
uint donations = fundraiser.tokenBalance(token);
uint granted = tokenBalance(token);
return donations > granted ? granted : donations;
}
| function matchable(address token) private view returns (uint) {
uint donations = fundraiser.tokenBalance(token);
uint granted = tokenBalance(token);
return donations > granted ? granted : donations;
}
| 38,130 |
10 | // Checks that the mapping key is valid (unique) | function _isMappingKeyValid(string calldata key) internal view {
require(pools[key] == address(0), "PF:POOL_ID_ALREADY_EXISTS");
}
| function _isMappingKeyValid(string calldata key) internal view {
require(pools[key] == address(0), "PF:POOL_ID_ALREADY_EXISTS");
}
| 18,627 |
10 | // updates duration (in seconds for the moment) | if( endTime - block.timestamp < 5 ){
endTime += 3; // will be more in real contract, just testing behavior
claimTime += 3; // update claim time too
}
| if( endTime - block.timestamp < 5 ){
endTime += 3; // will be more in real contract, just testing behavior
claimTime += 3; // update claim time too
}
| 34,198 |
137 | // Overrides Crowdsale fund forwarding, sending funds to escrow. / | function _forwardFunds() internal {
_escrow.deposit.value(msg.value)(_msgSender());
}
| function _forwardFunds() internal {
_escrow.deposit.value(msg.value)(_msgSender());
}
| 24,443 |
54 | // eth:dge2 pairs, @_ethAmount = input eth amount, return @_amounts = get dge1 amount | function getEthExDgeAmount(uint256 _ethAmount) public view returns(uint[] memory _dgeAmounts) {
IUniswapV2Router02 uniswpair = IUniswapV2Router02(uniswapV2Router02Addr);
address[] memory path;
path = new address[](2);
path[0] = weth;
path[1] = dgeContractAddr1;
return uniswpair.getAmountsOut(_ethAmount, path);
}
| function getEthExDgeAmount(uint256 _ethAmount) public view returns(uint[] memory _dgeAmounts) {
IUniswapV2Router02 uniswpair = IUniswapV2Router02(uniswapV2Router02Addr);
address[] memory path;
path = new address[](2);
path[0] = weth;
path[1] = dgeContractAddr1;
return uniswpair.getAmountsOut(_ethAmount, path);
}
| 9,413 |
3 | // return string The string "Name" | function name() external view returns (string memory);
| function name() external view returns (string memory);
| 53,915 |
200 | // Withdraw LP tokens. Only non-locked LP and Locked LP after lock period can be withdrawed | function withdraw(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: not good");
require(now > user.lastDepositTime + user.timelock, "Your LP is LOCKed for the moment");
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accMooPerShare).div(1e12).sub(user.rewardDebt);
uint256 depositduration = 0;
uint256 subrate = 1;
depositduration = now.sub(user.lastDepositTime);
if(now < (user.lastDepositTime + diminish) ){
subrate = depositduration.div(diminish);
}
if(pending > 0) {
safeMooTransfer(msg.sender, pending.mul(subrate));
safeMooTransfer(burnaddr, pending.sub(pending.mul(subrate)));
}
if(_amount > 0) {
user.amount = user.amount.sub(_amount);
pool.lpToken.safeTransfer(address(msg.sender), _amount);
}
user.lastDepositTime = now.sub(depositduration.div(2));
user.rewardDebt = user.amount.mul(pool.accMooPerShare).div(1e12);
emit Withdraw(msg.sender, _pid, _amount);
}
| function withdraw(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: not good");
require(now > user.lastDepositTime + user.timelock, "Your LP is LOCKed for the moment");
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accMooPerShare).div(1e12).sub(user.rewardDebt);
uint256 depositduration = 0;
uint256 subrate = 1;
depositduration = now.sub(user.lastDepositTime);
if(now < (user.lastDepositTime + diminish) ){
subrate = depositduration.div(diminish);
}
if(pending > 0) {
safeMooTransfer(msg.sender, pending.mul(subrate));
safeMooTransfer(burnaddr, pending.sub(pending.mul(subrate)));
}
if(_amount > 0) {
user.amount = user.amount.sub(_amount);
pool.lpToken.safeTransfer(address(msg.sender), _amount);
}
user.lastDepositTime = now.sub(depositduration.div(2));
user.rewardDebt = user.amount.mul(pool.accMooPerShare).div(1e12);
emit Withdraw(msg.sender, _pid, _amount);
}
| 8,625 |
349 | // Create a new bytes structure around [from, to) in-place. | assembly {
result := add(b, from)
mstore(result, sub(to, from))
}
| assembly {
result := add(b, from)
mstore(result, sub(to, from))
}
| 16,112 |
9 | // Returns the number of referral links used by a sender_campaignId id of the campaign _senderAddress address of the tokenreturn the number of referral links used by a sender / | function campaignReferralLinks(uint256 _campaignId, address _senderAddress)
external
view
override
returns (uint256)
| function campaignReferralLinks(uint256 _campaignId, address _senderAddress)
external
view
override
returns (uint256)
| 24,211 |
0 | // Abstract Storage Contract to pad the first 32 slots of storage/Superfluid/MUST be the FIRST contract inherited to pad the first 32 slots. The slots are padded to/ ensure the implementation contract (SuperToken.sol) does not override any auxiliary state/ variables. For more info see `./docs/StorageLayout.md`. | abstract contract SuperTokenStorage {
uint256[32] internal _storagePaddings;
} | abstract contract SuperTokenStorage {
uint256[32] internal _storagePaddings;
} | 2,264 |
293 | // 1 token causes rounding error with withdrawUnderlying | if (balanceOfToken(address(cToken)) > 1) {
_withdrawSome(deposits.sub(borrows));
}
| if (balanceOfToken(address(cToken)) > 1) {
_withdrawSome(deposits.sub(borrows));
}
| 44,690 |
1 | // approve rewarder to spend | liquidityToken.approve(address(rewardPool), type(uint256).max);
| liquidityToken.approve(address(rewardPool), type(uint256).max);
| 35,583 |
335 | // Redeemed amount represented in decimals of asset | uint256 redeemAmount;
| uint256 redeemAmount;
| 43,150 |
4 | // Get the address of the owner/ return The address of the owner. | function owner() external view returns (address);
| function owner() external view returns (address);
| 10,921 |
211 | // IGarden Interface for operating with a Garden. / | interface ICoreGarden {
/* ============ Constructor ============ */
/* ============ View ============ */
function privateGarden() external view returns (bool);
function publicStrategists() external view returns (bool);
function publicStewards() external view returns (bool);
function controller() external view returns (IBabController);
function creator() external view returns (address);
function isGardenStrategy(address _strategy) external view returns (bool);
function getContributor(address _contributor)
external
view
returns (
uint256,
uint256,
uint256,
uint256,
uint256,
uint256,
uint256,
uint256,
uint256,
uint256
);
function reserveAsset() external view returns (address);
function totalContributors() external view returns (uint256);
function gardenInitializedAt() external view returns (uint256);
function minContribution() external view returns (uint256);
function depositHardlock() external view returns (uint256);
function minLiquidityAsset() external view returns (uint256);
function minStrategyDuration() external view returns (uint256);
function maxStrategyDuration() external view returns (uint256);
function reserveAssetRewardsSetAside() external view returns (uint256);
function absoluteReturns() external view returns (int256);
function totalStake() external view returns (uint256);
function minVotesQuorum() external view returns (uint256);
function minVoters() external view returns (uint256);
function maxDepositLimit() external view returns (uint256);
function strategyCooldownPeriod() external view returns (uint256);
function getStrategies() external view returns (address[] memory);
function extraCreators(uint256 index) external view returns (address);
function getFinalizedStrategies() external view returns (address[] memory);
function strategyMapping(address _strategy) external view returns (bool);
function getLockedBalance(address _contributor) external view returns (uint256);
function keeperDebt() external view returns (uint256);
function totalKeeperFees() external view returns (uint256);
function lastPricePerShare() external view returns (uint256);
function lastPricePerShareTS() external view returns (uint256);
function pricePerShareDecayRate() external view returns (uint256);
function pricePerShareDelta() external view returns (uint256);
/* ============ Write ============ */
function deposit(
uint256 _reserveAssetQuantity,
uint256 _minGardenTokenReceiveQuantity,
address _to,
bool mintNFT
) external payable;
function depositBySig(
uint256 _amountIn,
uint256 _minAmountOut,
bool _mintNft,
uint256 _nonce,
uint256 _maxFee,
uint256 _pricePerShare,
uint256 _fee,
uint8 v,
bytes32 r,
bytes32 s
) external;
function withdraw(
uint256 _gardenTokenQuantity,
uint256 _minReserveReceiveQuantity,
address payable _to,
bool _withPenalty,
address _unwindStrategy
) external;
function withdrawBySig(
uint256 _gardenTokenQuantity,
uint256 _minReserveReceiveQuantity,
uint256 _nonce,
uint256 _maxFee,
bool _withPenalty,
address _unwindStrategy,
uint256 _pricePerShare,
uint256 _strategyNAV,
uint256 _fee,
uint8 v,
bytes32 r,
bytes32 s
) external;
function claimReturns(address[] calldata _finalizedStrategies) external;
function claimRewardsBySig(
uint256 _babl,
uint256 _profits,
uint256 _nonce,
uint256 _maxFee,
uint256 _fee,
uint8 v,
bytes32 r,
bytes32 s
) external;
}
| interface ICoreGarden {
/* ============ Constructor ============ */
/* ============ View ============ */
function privateGarden() external view returns (bool);
function publicStrategists() external view returns (bool);
function publicStewards() external view returns (bool);
function controller() external view returns (IBabController);
function creator() external view returns (address);
function isGardenStrategy(address _strategy) external view returns (bool);
function getContributor(address _contributor)
external
view
returns (
uint256,
uint256,
uint256,
uint256,
uint256,
uint256,
uint256,
uint256,
uint256,
uint256
);
function reserveAsset() external view returns (address);
function totalContributors() external view returns (uint256);
function gardenInitializedAt() external view returns (uint256);
function minContribution() external view returns (uint256);
function depositHardlock() external view returns (uint256);
function minLiquidityAsset() external view returns (uint256);
function minStrategyDuration() external view returns (uint256);
function maxStrategyDuration() external view returns (uint256);
function reserveAssetRewardsSetAside() external view returns (uint256);
function absoluteReturns() external view returns (int256);
function totalStake() external view returns (uint256);
function minVotesQuorum() external view returns (uint256);
function minVoters() external view returns (uint256);
function maxDepositLimit() external view returns (uint256);
function strategyCooldownPeriod() external view returns (uint256);
function getStrategies() external view returns (address[] memory);
function extraCreators(uint256 index) external view returns (address);
function getFinalizedStrategies() external view returns (address[] memory);
function strategyMapping(address _strategy) external view returns (bool);
function getLockedBalance(address _contributor) external view returns (uint256);
function keeperDebt() external view returns (uint256);
function totalKeeperFees() external view returns (uint256);
function lastPricePerShare() external view returns (uint256);
function lastPricePerShareTS() external view returns (uint256);
function pricePerShareDecayRate() external view returns (uint256);
function pricePerShareDelta() external view returns (uint256);
/* ============ Write ============ */
function deposit(
uint256 _reserveAssetQuantity,
uint256 _minGardenTokenReceiveQuantity,
address _to,
bool mintNFT
) external payable;
function depositBySig(
uint256 _amountIn,
uint256 _minAmountOut,
bool _mintNft,
uint256 _nonce,
uint256 _maxFee,
uint256 _pricePerShare,
uint256 _fee,
uint8 v,
bytes32 r,
bytes32 s
) external;
function withdraw(
uint256 _gardenTokenQuantity,
uint256 _minReserveReceiveQuantity,
address payable _to,
bool _withPenalty,
address _unwindStrategy
) external;
function withdrawBySig(
uint256 _gardenTokenQuantity,
uint256 _minReserveReceiveQuantity,
uint256 _nonce,
uint256 _maxFee,
bool _withPenalty,
address _unwindStrategy,
uint256 _pricePerShare,
uint256 _strategyNAV,
uint256 _fee,
uint8 v,
bytes32 r,
bytes32 s
) external;
function claimReturns(address[] calldata _finalizedStrategies) external;
function claimRewardsBySig(
uint256 _babl,
uint256 _profits,
uint256 _nonce,
uint256 _maxFee,
uint256 _fee,
uint8 v,
bytes32 r,
bytes32 s
) external;
}
| 67,893 |
100 | // multiply by e^2^(-2) | if ((x & 0x040000000000000000000000000000000) != 0)
res = (res * 0x1368b2fc6f9609fe7aceb46aa619baed5) / 0x0bc5ab1b16779be3575bd8f0520a9f21f;
| if ((x & 0x040000000000000000000000000000000) != 0)
res = (res * 0x1368b2fc6f9609fe7aceb46aa619baed5) / 0x0bc5ab1b16779be3575bd8f0520a9f21f;
| 1,254 |
93 | // Keep track of user ticket ids for a given lotteryId | mapping(address => mapping(uint256 => uint256[])) private _userTicketIdsPerLotteryId;
| mapping(address => mapping(uint256 => uint256[])) private _userTicketIdsPerLotteryId;
| 10,101 |
90 | // subtract send balanced | _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
| _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
| 35,895 |
155 | // Swap Index mapping & remap the latest group ID if this is not the last group | groups[ein][_groupIndex] = groups[ein][currentGroupIndex];
groupCount[ein] = _stichSortOrder(groupOrder[ein], _groupIndex, currentGroupIndex, 0);
| groups[ein][_groupIndex] = groups[ein][currentGroupIndex];
groupCount[ein] = _stichSortOrder(groupOrder[ein], _groupIndex, currentGroupIndex, 0);
| 36,929 |
0 | // wallet of developer | address public developer;
| address public developer;
| 5,351 |
0 | // 0x80ac58cd ===bytes4(keccak256('balanceOf(address)')) ^bytes4(keccak256('ownerOf(uint256)')) ^bytes4(keccak256('approve(address,uint256)')) ^bytes4(keccak256('getApproved(uint256)')) ^bytes4(keccak256('setApprovalForAll(address,bool)')) ^bytes4(keccak256('isApprovedForAll(address,address)')) ^bytes4(keccak256('transferFrom(address,address,uint256)')) ^bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) / |
bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f;
|
bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f;
| 5,473 |
5 | // We only want to do work in the case where the agent whose Revoke the agent's authorization. | delete self.authorized[agent];
| delete self.authorized[agent];
| 23,099 |
68 | // | | function initializedComplete() external returns (bool) {
// Controller Role Required
require(hasRole(CONTROLLER_ROLE, msg.sender));
// Citadel Unitialized
require(CITADEL_INITIALIZED == false);
// Toggle Citadel Intialized
CITADEL_INITIALIZED = true;
return CITADEL_INITIALIZED;
}
| function initializedComplete() external returns (bool) {
// Controller Role Required
require(hasRole(CONTROLLER_ROLE, msg.sender));
// Citadel Unitialized
require(CITADEL_INITIALIZED == false);
// Toggle Citadel Intialized
CITADEL_INITIALIZED = true;
return CITADEL_INITIALIZED;
}
| 81,790 |
63 | // Upgrade radbros from v1. Public function for users to upgrade from v1 contract./5% chance of winning a radbro/10% chance of winning 100 $RAD | function upgradeFromV1(
uint256[] calldata radbroIds,
bool claimRadcoin,
uint256 radcoinToUpgrade
| function upgradeFromV1(
uint256[] calldata radbroIds,
bool claimRadcoin,
uint256 radcoinToUpgrade
| 38,748 |
36 | // locked token structure / | struct lockToken {
uint256 amount;
uint256 validity;
bool claimed;
}
| struct lockToken {
uint256 amount;
uint256 validity;
bool claimed;
}
| 14,587 |
72 | // return the bucket's share | return MathHelpers.getPartialAmount(
lentPrincipal,
principalTotal,
owedAmount
);
| return MathHelpers.getPartialAmount(
lentPrincipal,
principalTotal,
owedAmount
);
| 20,697 |
46 | // Using this function might breaks CORE functionally - be careful | function renounceCanTransfer() public {
_removeCanTransfer(_msgSender());
}
| function renounceCanTransfer() public {
_removeCanTransfer(_msgSender());
}
| 32,102 |
38 | // Checks whether the cap has been reached.return Whether the cap was reached / | function capReached() public view returns (bool) {
return tokensRaised >= cap;
}
| function capReached() public view returns (bool) {
return tokensRaised >= cap;
}
| 5,468 |
9 | // Revert with a standard message if `account` is missing `role`. The format of the revert reason is given by the following regular expression: | * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*/
function _checkRole(bytes32 role, address account) internal view {
if (!hasRole(role, account)) {
revert(
string(
abi.encodePacked(
'AccessControl: account ',
Strings.toHexString(uint160(account), 20),
' is missing role ',
Strings.toHexString(uint256(role), 32)
)
)
);
}
}
| * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*/
function _checkRole(bytes32 role, address account) internal view {
if (!hasRole(role, account)) {
revert(
string(
abi.encodePacked(
'AccessControl: account ',
Strings.toHexString(uint160(account), 20),
' is missing role ',
Strings.toHexString(uint256(role), 32)
)
)
);
}
}
| 10,436 |
1 | // This message defenition shoult be autogenerated from ROS message description language.TODO: message generator implementation. / | contract StdString is Message {
string public data;
function StdString(string _data) {
data = _data;
}
}
| contract StdString is Message {
string public data;
function StdString(string _data) {
data = _data;
}
}
| 10,926 |
691 | // UserInfo storage user = userInfo[msg.sender]; | IERC20(pToken).safeTransferFrom(address(msg.sender), address(this), amount);
| IERC20(pToken).safeTransferFrom(address(msg.sender), address(this), amount);
| 30,903 |
9 | // the curve LP token address for the particular pool | IERC20 public curveLPToken;
| IERC20 public curveLPToken;
| 49,289 |
136 | // remove a winner project from the registy | function _removeWinnerProject(address holderAddress) private onlyMinter {
// delete from _projects array
delete _projects[_projectsData[holderAddress].projectID];
// delete from _projectsData mapping
delete _projectsData[holderAddress];
}
| function _removeWinnerProject(address holderAddress) private onlyMinter {
// delete from _projects array
delete _projects[_projectsData[holderAddress].projectID];
// delete from _projectsData mapping
delete _projectsData[holderAddress];
}
| 21,932 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.