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 |
|---|---|---|---|---|
23 | // Execute reduce reserve and burn on multiple cTokens cTokens The token address list / | function dispatchMultiple(address[] memory cTokens) external {
for (uint i = 0; i < cTokens.length; i++) {
this.dispatch(cTokens[i], true);
}
IBurner(usdcBurner).burn(usdcAddress);
}
| function dispatchMultiple(address[] memory cTokens) external {
for (uint i = 0; i < cTokens.length; i++) {
this.dispatch(cTokens[i], true);
}
IBurner(usdcBurner).burn(usdcAddress);
}
| 27,875 |
67 | // This is denominated in Fragments, because the gons-fragments conversion might change before it's fully paid. | mapping (address => mapping (address => uint256)) private _allowedFragments;
| mapping (address => mapping (address => uint256)) private _allowedFragments;
| 18,735 |
5 | // Returns the configuration of the distribution for a certain asset asset The address of the reference asset of the distributionreturn The asset index, the emission per second and the last updated timestamp / | function getAssetData(address asset) external view returns (uint256, uint256, uint256);
| function getAssetData(address asset) external view returns (uint256, uint256, uint256);
| 5,956 |
54 | // Get latest recorded price from oracleIf it falls below allowed buffer or has not updated, it would be invalid. / | function _getPriceFromOracle() internal view returns (uint80, int256) {
uint256 leastAllowedTimestamp = block.timestamp + oracleUpdateAllowance;
(uint80 roundId, int256 price, , uint256 timestamp, ) = oracle.latestRoundData();
require(timestamp <= leastAllowedTimestamp, "Oracle update exceeded max timestamp allowance");
require(
uint256(roundId) > oracleLatestRoundId,
"Oracle update roundId must be larger than oracleLatestRoundId"
);
return (roundId, price);
}
| function _getPriceFromOracle() internal view returns (uint80, int256) {
uint256 leastAllowedTimestamp = block.timestamp + oracleUpdateAllowance;
(uint80 roundId, int256 price, , uint256 timestamp, ) = oracle.latestRoundData();
require(timestamp <= leastAllowedTimestamp, "Oracle update exceeded max timestamp allowance");
require(
uint256(roundId) > oracleLatestRoundId,
"Oracle update roundId must be larger than oracleLatestRoundId"
);
return (roundId, price);
}
| 4,863 |
288 | // Auction State | struct Auction {
| struct Auction {
| 70,888 |
587 | // Keep track of all ETH wrapped into WETH as part of a deposit. | if (_isETH(asset)) {
ethWrapped = ethWrapped.add(amount);
}
| if (_isETH(asset)) {
ethWrapped = ethWrapped.add(amount);
}
| 82,146 |
284 | // Gets the penalty amount. If the message hash does not exist instakes mapping it will return zero amount. If the message isalready progressed or revoked then the penalty amount will bezero._messageHash Message hash. return penalty_ Penalty amount. / | function penalty(bytes32 _messageHash)
external
view
returns (uint256 penalty_)
| function penalty(bytes32 _messageHash)
external
view
returns (uint256 penalty_)
| 25,232 |
0 | // the address of the deployed EIP712 verifier contract | address internal _eip712;
| address internal _eip712;
| 26,421 |
26 | // Throw if box is destroyedboxId id of the box / | function onlyNotBrokenBox(uint256 boxId) internal view {
require(!destroyedBoxes[boxId], "e3");
}
| function onlyNotBrokenBox(uint256 boxId) internal view {
require(!destroyedBoxes[boxId], "e3");
}
| 46,563 |
1 | // Contract constructor/Calls SwipeRegistry contract constructor | constructor() public SwipeRegistry("Swipe Governance Timelock Proxy") {}
}
| constructor() public SwipeRegistry("Swipe Governance Timelock Proxy") {}
}
| 33,305 |
82 | // DODOMineV3 Registry DODO BreederRegister DODOMineV3 Pools/ | contract DODOMineV3Registry is InitializableOwnable, IDODOMineV3Registry {
mapping (address => bool) public isAdminListed;
// ============ Registry ============
// minePool -> stakeToken
mapping(address => address) public _MINE_REGISTRY_;
// lpToken -> minePool
mapping(address => address[]) public _LP_REGISTRY_;
// singleToken -> minePool
mapping(address => address[]) public _SINGLE_REGISTRY_;
// ============ Events ============
event NewMineV3(address mine, address stakeToken, bool isLpToken);
event RemoveMineV3(address mine, address stakeToken);
event addAdmin(address admin);
event removeAdmin(address admin);
function addMineV3(
address mine,
bool isLpToken,
address stakeToken
) override external {
require(isAdminListed[msg.sender], "ACCESS_DENIED");
_MINE_REGISTRY_[mine] = stakeToken;
if(isLpToken) {
_LP_REGISTRY_[stakeToken].push(mine);
}else {
_SINGLE_REGISTRY_[stakeToken].push(mine);
}
emit NewMineV3(mine, stakeToken, isLpToken);
}
// ============ Admin Operation Functions ============
function removeMineV3(
address mine,
bool isLpToken,
address stakeToken
) external onlyOwner {
_MINE_REGISTRY_[mine] = address(0);
if(isLpToken) {
uint256 len = _LP_REGISTRY_[stakeToken].length;
for (uint256 i = 0; i < len; i++) {
if (mine == _LP_REGISTRY_[stakeToken][i]) {
if(i != len - 1) {
_LP_REGISTRY_[stakeToken][i] = _LP_REGISTRY_[stakeToken][len - 1];
}
_LP_REGISTRY_[stakeToken].pop();
break;
}
}
}else {
uint256 len = _SINGLE_REGISTRY_[stakeToken].length;
for (uint256 i = 0; i < len; i++) {
if (mine == _SINGLE_REGISTRY_[stakeToken][i]) {
if(i != len - 1) {
_SINGLE_REGISTRY_[stakeToken][i] = _SINGLE_REGISTRY_[stakeToken][len - 1];
}
_SINGLE_REGISTRY_[stakeToken].pop();
break;
}
}
}
emit RemoveMineV3(mine, stakeToken);
}
function addAdminList (address contractAddr) external onlyOwner {
isAdminListed[contractAddr] = true;
emit addAdmin(contractAddr);
}
function removeAdminList (address contractAddr) external onlyOwner {
isAdminListed[contractAddr] = false;
emit removeAdmin(contractAddr);
}
}
| contract DODOMineV3Registry is InitializableOwnable, IDODOMineV3Registry {
mapping (address => bool) public isAdminListed;
// ============ Registry ============
// minePool -> stakeToken
mapping(address => address) public _MINE_REGISTRY_;
// lpToken -> minePool
mapping(address => address[]) public _LP_REGISTRY_;
// singleToken -> minePool
mapping(address => address[]) public _SINGLE_REGISTRY_;
// ============ Events ============
event NewMineV3(address mine, address stakeToken, bool isLpToken);
event RemoveMineV3(address mine, address stakeToken);
event addAdmin(address admin);
event removeAdmin(address admin);
function addMineV3(
address mine,
bool isLpToken,
address stakeToken
) override external {
require(isAdminListed[msg.sender], "ACCESS_DENIED");
_MINE_REGISTRY_[mine] = stakeToken;
if(isLpToken) {
_LP_REGISTRY_[stakeToken].push(mine);
}else {
_SINGLE_REGISTRY_[stakeToken].push(mine);
}
emit NewMineV3(mine, stakeToken, isLpToken);
}
// ============ Admin Operation Functions ============
function removeMineV3(
address mine,
bool isLpToken,
address stakeToken
) external onlyOwner {
_MINE_REGISTRY_[mine] = address(0);
if(isLpToken) {
uint256 len = _LP_REGISTRY_[stakeToken].length;
for (uint256 i = 0; i < len; i++) {
if (mine == _LP_REGISTRY_[stakeToken][i]) {
if(i != len - 1) {
_LP_REGISTRY_[stakeToken][i] = _LP_REGISTRY_[stakeToken][len - 1];
}
_LP_REGISTRY_[stakeToken].pop();
break;
}
}
}else {
uint256 len = _SINGLE_REGISTRY_[stakeToken].length;
for (uint256 i = 0; i < len; i++) {
if (mine == _SINGLE_REGISTRY_[stakeToken][i]) {
if(i != len - 1) {
_SINGLE_REGISTRY_[stakeToken][i] = _SINGLE_REGISTRY_[stakeToken][len - 1];
}
_SINGLE_REGISTRY_[stakeToken].pop();
break;
}
}
}
emit RemoveMineV3(mine, stakeToken);
}
function addAdminList (address contractAddr) external onlyOwner {
isAdminListed[contractAddr] = true;
emit addAdmin(contractAddr);
}
function removeAdminList (address contractAddr) external onlyOwner {
isAdminListed[contractAddr] = false;
emit removeAdmin(contractAddr);
}
}
| 42,418 |
172 | // Calculates token amount available for holder to be releasedholder an address to query releasable amount forreturn ilvAmt amount of ILV tokens available for withdrawal (see release function) / | function releasableAmount(address holder) public view returns (uint96 ilvAmt) {
// calculate a difference between amount of tokens available for
// withdrawal currently (vested amount) and amount of tokens already withdrawn (released)
return vestedAmount(holder) - userRecords[holder].ilvReleased;
}
| function releasableAmount(address holder) public view returns (uint96 ilvAmt) {
// calculate a difference between amount of tokens available for
// withdrawal currently (vested amount) and amount of tokens already withdrawn (released)
return vestedAmount(holder) - userRecords[holder].ilvReleased;
}
| 49,772 |
18 | // expmods[14] = trace_generator^(255trace_length / 256). | mstore(0x4440, expmod(/*trace_generator*/ mload(0x440), div(mul(255, /*trace_length*/ mload(0x80)), 256), PRIME))
| mstore(0x4440, expmod(/*trace_generator*/ mload(0x440), div(mul(255, /*trace_length*/ mload(0x80)), 256), PRIME))
| 21,444 |
19 | // initiate the transfer to the specified address and the amount of tokens going to it | adbank.transfer(_addrs[i], _amounts[i]);
| adbank.transfer(_addrs[i], _amounts[i]);
| 35,466 |
250 | // Amount is zero. | error AmountIsZero();
| error AmountIsZero();
| 21,848 |
155 | // Check if whitelisted token is whitelisted return bool true if whitelisted, false if not/ | function isWhitelisted(address _stablecoin) public view returns (bool) {
return tokenStorage_CD.whitelist(_stablecoin);
}
| function isWhitelisted(address _stablecoin) public view returns (bool) {
return tokenStorage_CD.whitelist(_stablecoin);
}
| 19,317 |
3 | // EIP-712 boilerplate begins | event SignatureExtracted(address indexed signer, string action);
string private constant EIP712_DOMAIN = "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)";
string private constant UNIT_TYPE = "Unit(string actionType,uint256 timestamp,string authorizer)";
| event SignatureExtracted(address indexed signer, string action);
string private constant EIP712_DOMAIN = "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)";
string private constant UNIT_TYPE = "Unit(string actionType,uint256 timestamp,string authorizer)";
| 31,570 |
12 | // The percent of each profitable harvest that will go to the rewards contract. | uint256 public harvestFee;
| uint256 public harvestFee;
| 30,759 |
68 | // Method for Setting the Price of Each Tier of TokenIds _tierPrices Arrays of Tier ETH Price in Decimals / | function setTierPricesInEth(uint256[6] calldata _tierPrices) external onlyAdmin {
tierPricesInEth = _tierPrices;
}
| function setTierPricesInEth(uint256[6] calldata _tierPrices) external onlyAdmin {
tierPricesInEth = _tierPrices;
}
| 8,377 |
1 | // treasury and liquidity wallet | address treasuryWallet = address(0xA8F656435f632bBEAAA439E7A0f6A7ff96FF11b2);
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
mapping(address => bool) private _isExcludedFromFees;
mapping(address => bool) public automatedMarketMakerPairs;
event SendDividends(uint256 amount);
event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value);
event UpdateUniswapV2Router(
| address treasuryWallet = address(0xA8F656435f632bBEAAA439E7A0f6A7ff96FF11b2);
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
mapping(address => bool) private _isExcludedFromFees;
mapping(address => bool) public automatedMarketMakerPairs;
event SendDividends(uint256 amount);
event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value);
event UpdateUniswapV2Router(
| 53,522 |
116 | // Transfer amountInratio of tokenIn to treasury address | ERC20(tokenIn).safeTransferFrom(sender, treasury, amountIn);
| ERC20(tokenIn).safeTransferFrom(sender, treasury, amountIn);
| 32,979 |
158 | // Copied from https:github.com/optionality/clone-factory/blob/master/contracts/CloneFactory.sol | bytes20 addressBytes = bytes20(address(this));
assembly {
| bytes20 addressBytes = bytes20(address(this));
assembly {
| 875 |
126 | // Add a new Liquitdity PAIR to the pool. Can only be called by the owner. XXX DO NOT add the same Liquidity PAIR more than once. Rewards will be messed up if you do. | function add(uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock;
totalAllocPoint = totalAllocPoint.add(_allocPoint);
poolInfo.push(PoolInfo({
lpToken: _lpToken,
allocPoint: _allocPoint,
lastRewardBlock: lastRewardBlock,
accTokensPerShare: 0
}));
}
| function add(uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock;
totalAllocPoint = totalAllocPoint.add(_allocPoint);
poolInfo.push(PoolInfo({
lpToken: _lpToken,
allocPoint: _allocPoint,
lastRewardBlock: lastRewardBlock,
accTokensPerShare: 0
}));
}
| 869 |
48 | // 触发赎回BAB事件 | emit RedeemedBonds(msg.sender, amount);
| emit RedeemedBonds(msg.sender, amount);
| 11,103 |
216 | // Convert underlying value into corresponding number of harvest vault shares | function _toHarvestVaultTokens(uint256 amount) internal view returns (uint256) {
uint256 ppfs = IHarvestVault(harvestVault).getPricePerFullShare();
uint256 unit = IHarvestVault(harvestVault).underlyingUnit();
return amount.mul(unit).div(ppfs);
}
| function _toHarvestVaultTokens(uint256 amount) internal view returns (uint256) {
uint256 ppfs = IHarvestVault(harvestVault).getPricePerFullShare();
uint256 unit = IHarvestVault(harvestVault).underlyingUnit();
return amount.mul(unit).div(ppfs);
}
| 34,836 |
0 | // Creates an instance of `PaymentSplitter` where each account in `payees` is assigned the number of shares atthe matching position in the `shares` array. All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be noduplicates in `payees`. / | constructor(address[] memory payees, uint256[] memory shares_) payable {
require(payees.length == shares_.length, 'PaymentSplitter: length mismatch');
require(payees.length > 0, 'PaymentSplitter: no payees');
for (uint256 i = 0; i < payees.length; i++) {
_addPayee(payees[i], shares_[i]);
}
}
| constructor(address[] memory payees, uint256[] memory shares_) payable {
require(payees.length == shares_.length, 'PaymentSplitter: length mismatch');
require(payees.length > 0, 'PaymentSplitter: no payees');
for (uint256 i = 0; i < payees.length; i++) {
_addPayee(payees[i], shares_[i]);
}
}
| 12,052 |
169 | // record new reward | uint256 newRewardRate;
if (block.timestamp >= periodFinish_) {
newRewardRate = reward / DURATION_;
} else {
| uint256 newRewardRate;
if (block.timestamp >= periodFinish_) {
newRewardRate = reward / DURATION_;
} else {
| 44,244 |
64 | // Gets the evidengeGroupID for a given item and request. _itemID The ID of the item. _requestID The ID of the request.return The evidenceGroupID / | function getEvidenceGroupID(bytes32 _itemID, uint256 _requestID) external pure returns (uint256);
| function getEvidenceGroupID(bytes32 _itemID, uint256 _requestID) external pure returns (uint256);
| 58,973 |
21 | // recalculate current collateral and debt values in fUSD | uint256 cCollateralValue = collateralValue(msg.sender);
uint256 cDebtValue = debtValue(msg.sender);
| uint256 cCollateralValue = collateralValue(msg.sender);
uint256 cDebtValue = debtValue(msg.sender);
| 1,336 |
3 | // withdraws the WETH _reserves of msg.sender. amount amount of pWETH to withdraw and receive native ETH to address of the user who will receive native ETH / | function withdrawETH(uint256 amount, address to)
external
override
nonReentrant
| function withdrawETH(uint256 amount, address to)
external
override
nonReentrant
| 34,862 |
384 | // Sets price of 1 FROM = <PRICE> TO |
function setPrice(
address from,
address to,
uint256 price
) external {
|
function setPrice(
address from,
address to,
uint256 price
) external {
| 1,727 |
29 | // Withdraw all staked tokens (and collect reward tokens if requested) claimRewardToken whether to claim reward tokens / | function withdrawAll(bool claimRewardToken) external nonReentrant {
_withdraw(userInfo[msg.sender].shares, claimRewardToken);
}
| function withdrawAll(bool claimRewardToken) external nonReentrant {
_withdraw(userInfo[msg.sender].shares, claimRewardToken);
}
| 43,118 |
316 | // initial funding for the treasury: | mintToAccount(Constants.getTreasuryAddress(), 2000000e18); // 2 million DSD
| mintToAccount(Constants.getTreasuryAddress(), 2000000e18); // 2 million DSD
| 27,963 |
1 | // if everything is ok | require(
campaign.deadline < block.timestamp,
"The deadline should be a day in the future."
);
campaign.owner = _owner;
campaign.title = _tittle;
campaign.desription = _descriptions;
campaign.target = _target;
campaign.deadline = _deadline;
| require(
campaign.deadline < block.timestamp,
"The deadline should be a day in the future."
);
campaign.owner = _owner;
campaign.title = _tittle;
campaign.desription = _descriptions;
campaign.target = _target;
campaign.deadline = _deadline;
| 10,673 |
32 | // Only ever called if oracle needs initialization | function canOracleBeCreatedForRoute(address asset, address compareTo) external view returns (bool);
| function canOracleBeCreatedForRoute(address asset, address compareTo) external view returns (bool);
| 24,007 |
219 | // if transcoder called reward for 'currentRound' but not for 'currentRound - 1' (missed reward call) retroactively calculate what its cumulativeRewardFactor would have been for 'currentRound - 1' (cfr. previous lastRewardRound for transcoder) based on rewards for currentRound | IMinter mtr = minter();
uint256 rewards = MathUtils.percOf(mtr.currentMintableTokens().add(mtr.currentMintedTokens()), totalStake, currentRoundTotalActiveStake);
uint256 transcoderCommissionRewards = MathUtils.percOf(rewards, earningsPool.transcoderRewardCut);
uint256 delegatorsRewards = rewards.sub(transcoderCommissionRewards);
prevEarningsPool.cumulativeRewardFactor = MathUtils.percOf(
earningsPool.cumulativeRewardFactor,
totalStake,
delegatorsRewards.add(totalStake)
);
| IMinter mtr = minter();
uint256 rewards = MathUtils.percOf(mtr.currentMintableTokens().add(mtr.currentMintedTokens()), totalStake, currentRoundTotalActiveStake);
uint256 transcoderCommissionRewards = MathUtils.percOf(rewards, earningsPool.transcoderRewardCut);
uint256 delegatorsRewards = rewards.sub(transcoderCommissionRewards);
prevEarningsPool.cumulativeRewardFactor = MathUtils.percOf(
earningsPool.cumulativeRewardFactor,
totalStake,
delegatorsRewards.add(totalStake)
);
| 35,235 |
97 | // compute zeta_n.[T2] | success := staticcall(gas(), 7, add(accumulator_ptr, 0x40), 0x60, add(accumulator_ptr, 0x40), 0x40)
| success := staticcall(gas(), 7, add(accumulator_ptr, 0x40), 0x60, add(accumulator_ptr, 0x40), 0x40)
| 18,219 |
300 | // Emitted when reward of amount is distributed into account | event RewardDistributed(
address iToken,
address account,
uint256 amount,
uint256 accountIndex
);
| event RewardDistributed(
address iToken,
address account,
uint256 amount,
uint256 accountIndex
);
| 57,855 |
44 | // Tokens that don't implement the `decimals` method are not supported. | uint256 tokenDecimals = ERC20(address(token)).decimals();
| uint256 tokenDecimals = ERC20(address(token)).decimals();
| 18,045 |
194 | // addressstaker | mapping(address => Staker ) stakers;
| mapping(address => Staker ) stakers;
| 45,155 |
63 | // only importer contract is allowed to proceed | require(msg.sender == tokenImporter);
_;
| require(msg.sender == tokenImporter);
_;
| 26,412 |
7 | // Performs a batch deposit, asking for an additional fee payment. / | function batchDeposit(
bytes calldata pubkeys,
bytes calldata withdrawal_credentials,
bytes calldata signatures,
bytes32[] calldata deposit_data_roots
| function batchDeposit(
bytes calldata pubkeys,
bytes calldata withdrawal_credentials,
bytes calldata signatures,
bytes32[] calldata deposit_data_roots
| 19,957 |
94 | // How many ETH has provided. | uint256 investInput;
| uint256 investInput;
| 8,436 |
1 | // @inheritdoc IUniswapV3PoolImmutables | address public immutable override token0;
| address public immutable override token0;
| 24,899 |
2 | // Address controlling chaosnet status and beta operator addresses. | address public chaosnetOwner;
event BetaOperatorsAdded(address[] operators);
event ChaosnetOwnerRoleTransferred(
address oldChaosnetOwner,
address newChaosnetOwner
);
event ChaosnetDeactivated();
| address public chaosnetOwner;
event BetaOperatorsAdded(address[] operators);
event ChaosnetOwnerRoleTransferred(
address oldChaosnetOwner,
address newChaosnetOwner
);
event ChaosnetDeactivated();
| 19,063 |
78 | // Override for extensions that require an internal state to check for validity (current user contributions,etc.) beneficiary Address receiving the tokens weiAmount Value in wei involved in the purchase / | function _updatePurchasingState(address beneficiary, uint256 weiAmount) internal {
// solhint-disable-previous-line no-empty-blocks
}
| function _updatePurchasingState(address beneficiary, uint256 weiAmount) internal {
// solhint-disable-previous-line no-empty-blocks
}
| 35,887 |
99 | // transfer balance of remaining assets to caller, minus any needed for the loan | for (uint i = 0; i < assets.length; i++) {
if(vars.remainingAmounts[i] > 0)
IERC20(assets[i]).safeTransfer(vars.warpTeam, vars.remainingAmounts[i]);
}
| for (uint i = 0; i < assets.length; i++) {
if(vars.remainingAmounts[i] > 0)
IERC20(assets[i]).safeTransfer(vars.warpTeam, vars.remainingAmounts[i]);
}
| 49,373 |
166 | // Otherwise, just check the quantity. Ensure mint quantity doesn't exceed maxTotalMintableByWallet. | if (quantity + minterNumMinted > maxTotalMintableByWallet) {
revert MintQuantityExceedsMaxMintedPerWallet(
quantity + minterNumMinted,
maxTotalMintableByWallet
);
}
| if (quantity + minterNumMinted > maxTotalMintableByWallet) {
revert MintQuantityExceedsMaxMintedPerWallet(
quantity + minterNumMinted,
maxTotalMintableByWallet
);
}
| 46,218 |
178 | // Allow Owner to enroll Replica contract _replica the address of the Replica _domain the remote domain of the Home contract for the Replica / | function ownerEnrollReplica(address _replica, uint32 _domain)
external
onlyOwner
| function ownerEnrollReplica(address _replica, uint32 _domain)
external
onlyOwner
| 21,526 |
217 | // payees payment receiving addresses shares_ shares of addresses / | constructor(address[] memory payees, uint256[] memory shares_)
ERC721("HON - Heroes Token", "HRO")
PaymentSplitter(payees, shares_)
| constructor(address[] memory payees, uint256[] memory shares_)
ERC721("HON - Heroes Token", "HRO")
PaymentSplitter(payees, shares_)
| 1,590 |
89 | // round 19 | ark(i, q, 1197934381747032348421303489683932612752526046745577259575778515005162320212);
sbox_partial(i, q);
mix(i, q);
| ark(i, q, 1197934381747032348421303489683932612752526046745577259575778515005162320212);
sbox_partial(i, q);
mix(i, q);
| 24,395 |
86 | // Initialize sell card for future | function _initCardDetails(uint8 cardId, uint price) internal
returns (bool success)
| function _initCardDetails(uint8 cardId, uint price) internal
returns (bool success)
| 40,085 |
43 | // mark funder as premium collectors | coverData.setPremiumCollected(_coverId);
CoverRequest memory coverRequest = listingData.getCoverRequestById(
cover.requestId
);
| coverData.setPremiumCollected(_coverId);
CoverRequest memory coverRequest = listingData.getCoverRequestById(
cover.requestId
);
| 10,551 |
12 | // Return the bps rate for reserve pool. | function getReservePoolBps() external view returns (uint256);
| function getReservePoolBps() external view returns (uint256);
| 33,001 |
60 | // Add `elastic` to `total` and doubles `total.base`./ return (Rebase) The new total./ return base in relationship to `elastic`. | function add(
Rebase memory total,
uint256 elastic,
bool roundUp
| function add(
Rebase memory total,
uint256 elastic,
bool roundUp
| 9,145 |
10 | // - Emits a {MentaportAccount} event./ | function changeMentaportAccount(address _newAddress) external nonReentrant {
require(hasRole(MENTAPORT_ROLE, msg.sender), "Caller is not mentaport");
_mentaAccount = _newAddress;
emit MentaportAccount(msg.sender, _mentaAccount);
}
| function changeMentaportAccount(address _newAddress) external nonReentrant {
require(hasRole(MENTAPORT_ROLE, msg.sender), "Caller is not mentaport");
_mentaAccount = _newAddress;
emit MentaportAccount(msg.sender, _mentaAccount);
}
| 28,463 |
1 | // Security Check // Ensure this is an interest rate model contract. / | function isInterestRateModel() external pure returns (bool) {
return true;
}
| function isInterestRateModel() external pure returns (bool) {
return true;
}
| 36,804 |
40 | // When the token to delete is the last token, the swap operation is unnecessary | if (tokenIndex != lastTokenIndex) {
uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];
_ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
}
| if (tokenIndex != lastTokenIndex) {
uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];
_ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
}
| 4,788 |
33 | // COVERAGE CONTRIBUTION | uint256 coverageContribution =
totalCoveragedLiquidity.mul(PERCENTAGE_100).div(totalPoolLiquidity);
uint256 coverageLoss = _claimAmount.mul(coverageContribution).div(PERCENTAGE_100);
_updatePoolLiquidity(_policyBookAddress, coverageLoss, 0, PoolType.COVERAGE);
| uint256 coverageContribution =
totalCoveragedLiquidity.mul(PERCENTAGE_100).div(totalPoolLiquidity);
uint256 coverageLoss = _claimAmount.mul(coverageContribution).div(PERCENTAGE_100);
_updatePoolLiquidity(_policyBookAddress, coverageLoss, 0, PoolType.COVERAGE);
| 31,889 |
147 | // epoch | function getLastEpoch() public view returns (uint256) {
return lastExecutedAt.sub(startTime).div(period);
}
| function getLastEpoch() public view returns (uint256) {
return lastExecutedAt.sub(startTime).div(period);
}
| 44,593 |
169 | // liquidation cap at issuanceRatio is checked above | if (_deadlinePassed(liquidation.deadline)) {
return true;
}
| if (_deadlinePassed(liquidation.deadline)) {
return true;
}
| 1,413 |
332 | // Compute what percentage of the interest earned will go back to the Safe. | uint256 protocolFeePercent = master.clerk().getFeePercentageForSafe(this, asset);
| uint256 protocolFeePercent = master.clerk().getFeePercentageForSafe(this, asset);
| 34,927 |
1 | // Mint token using external token ID and URI. / | function mint(
address to,
uint256 tokenId,
string memory tokenURI
) public {
_mint(to, tokenId);
| function mint(
address to,
uint256 tokenId,
string memory tokenURI
) public {
_mint(to, tokenId);
| 6,701 |
12 | // Mint tokens up to CAP | if (token.totalSupply() < tokensCap) {
uint tokens = tokensCap.sub(token.totalSupply());
token.mint(remainingTokensWallet, tokens);
}
| if (token.totalSupply() < tokensCap) {
uint tokens = tokensCap.sub(token.totalSupply());
token.mint(remainingTokensWallet, tokens);
}
| 27,768 |
5 | // 0.1 ether corresponds the amount to send to Fomo3D for a chance at winning the airDropThis is sent within the constructor to bypass a modifier that checks for blank code from the message senderAs during construction a contract's code is blank.We then withdraw all earnings from fomo3d and selfdestruct to returns all funds to the main exploit contract. / | constructor() public {
if(!address(fomo3d).call.value(0.1 ether)()) {
fomo3d.withdraw();
selfdestruct(msg.sender);
}
}
| constructor() public {
if(!address(fomo3d).call.value(0.1 ether)()) {
fomo3d.withdraw();
selfdestruct(msg.sender);
}
}
| 70,632 |
13 | // Rejects the bid to supply to the pool. _poolId The Id of the pool. _ERC20Address The address of the funds contract. _bidId The Id of the bid. _lender The address of the lender. / | function RejectBid(
uint256 _poolId,
address _ERC20Address,
uint256 _bidId,
address _lender
| function RejectBid(
uint256 _poolId,
address _ERC20Address,
uint256 _bidId,
address _lender
| 32,685 |
12 | // ambassador program | mapping(address => bool) internal ambassadors_;
uint256 constant internal ambassadorMaxPurchase_ = 10 ether;
uint256 constant internal ambassadorQuota_ = 10 ether;
| mapping(address => bool) internal ambassadors_;
uint256 constant internal ambassadorMaxPurchase_ = 10 ether;
uint256 constant internal ambassadorQuota_ = 10 ether;
| 2,119 |
48 | // MARKET | struct Item {
bool exists;
uint256 index;
uint256 genes;
uint256 level;
uint256 price;
uint256 count;
}
| struct Item {
bool exists;
uint256 index;
uint256 genes;
uint256 level;
uint256 price;
uint256 count;
}
| 26,600 |
53 | // unlink publisher and subscriber | vars.sdata.subId = _UNALLOCATED_SUB_ID;
token.updateAgreementData(vars.sId, _encodeSubscriptionData(vars.sdata));
| vars.sdata.subId = _UNALLOCATED_SUB_ID;
token.updateAgreementData(vars.sId, _encodeSubscriptionData(vars.sdata));
| 5,215 |
15 | // Calls the permission manager and sets permissions via signature permissionManager The address of the permission manager permissions The permissions to set tokenId The token's id deadline The deadline timestamp by which the call must be mined for the approve to work v Must produce valid secp256k1 signature from the holder along with `r` and `s` r Must produce valid secp256k1 signature from the holder along with `v` and `s` s Must produce valid secp256k1 signature from the holder along with `r` and `v` / | function permissionPermit(
| function permissionPermit(
| 41,240 |
37 | // using the valid case inverted via one ! instead of invalid case with 3 ! to optimize gas usage | if (!((_status == 20 || _status == 21) && initiator_ == address(this))) {
revert AvoWallet__Unauthorized();
}
| if (!((_status == 20 || _status == 21) && initiator_ == address(this))) {
revert AvoWallet__Unauthorized();
}
| 25,462 |
55 | // Internal function to batch mint amounts of tokens with the given IDs to The address that will own the minted token ids IDs of the tokens to be minted values Amounts of the tokens to be minted data Data forwarded to `onERC1155Received` if `to` is a contract receiver / | function _batchMint(address to, uint256[] memory ids, uint256[] memory values, bytes memory data) internal {
require(to != address(0), "ERC1155: batch mint to the zero address");
require(ids.length == values.length, "ERC1155: IDs and values must have same lengths");
for(uint i = 0; i < ids.length; i++) {
_balances[ids[i]][to] = values[i].add(_balances[ids[i]][to]);
}
emit TransferBatch(msg.sender, address(0), to, ids, values);
_doSafeBatchTransferAcceptanceCheck(msg.sender, address(0), to, ids, values, data);
}
| function _batchMint(address to, uint256[] memory ids, uint256[] memory values, bytes memory data) internal {
require(to != address(0), "ERC1155: batch mint to the zero address");
require(ids.length == values.length, "ERC1155: IDs and values must have same lengths");
for(uint i = 0; i < ids.length; i++) {
_balances[ids[i]][to] = values[i].add(_balances[ids[i]][to]);
}
emit TransferBatch(msg.sender, address(0), to, ids, values);
_doSafeBatchTransferAcceptanceCheck(msg.sender, address(0), to, ids, values, data);
}
| 45,863 |
156 | // Lifecycle step which delivers the purchased SKUs to the recipient. Responsibilities: - Ensure the product is delivered to the recipient, if that is the contract's responsibility. - Handle any internal logic related to the delivery, including the remaining supply update; - Add any relevant extra data related to delivery in `purchase.deliveryData` and document how to interpret it. purchase The purchase conditions. / | function _delivery(PurchaseData memory purchase) internal virtual;
| function _delivery(PurchaseData memory purchase) internal virtual;
| 71,772 |
45 | // Constant governance parameters, fixed from the inception of this party. | GovernanceValues internal _governanceValues;
| GovernanceValues internal _governanceValues;
| 31,469 |
554 | // external function to set the base URI for all token IDs baseURI_ the new base uri / | function setBaseURI(string memory baseURI_) external onlyOwner {
_setBaseURI(baseURI_);
}
| function setBaseURI(string memory baseURI_) external onlyOwner {
_setBaseURI(baseURI_);
}
| 51,699 |
35 | // TO DO.We can do better here , by groupping publishMarketFeeTokens and consumeFeeTokens and have a singletransfer for each one, instead of doing it per dt.. | for (uint256 i = 0; i < ids; i++) {
(address publishMarketFeeAddress, address publishMarketFeeToken, uint256 publishMarketFeeAmount)
= IERC20Template(orders[i].tokenAddress).getPublishingMarketFee();
| for (uint256 i = 0; i < ids; i++) {
(address publishMarketFeeAddress, address publishMarketFeeToken, uint256 publishMarketFeeAmount)
= IERC20Template(orders[i].tokenAddress).getPublishingMarketFee();
| 29,335 |
95 | // Info of pool. | struct PoolInfo{
bool depositOpen;
uint256 depositFeeRate;
IERC20 depositToken;
uint256 depositMin;
uint256 depositTime;
uint256 depositOpenTime;
uint256 depositCloseTime;
bool voteTokenOpen;
uint256 voteTokenTime;
uint256 voteTokenOpenTime;
uint256 voteTokenCloseTime;
IERC20 targetToken;
uint256 profitShareRate;
}
| struct PoolInfo{
bool depositOpen;
uint256 depositFeeRate;
IERC20 depositToken;
uint256 depositMin;
uint256 depositTime;
uint256 depositOpenTime;
uint256 depositCloseTime;
bool voteTokenOpen;
uint256 voteTokenTime;
uint256 voteTokenOpenTime;
uint256 voteTokenCloseTime;
IERC20 targetToken;
uint256 profitShareRate;
}
| 32,838 |
2 | // This contract enables deposit and plant deom single tx on ethereum chain First potatoes are transferred to this contract Then they are deposited to ChildPotatoMigrator contract Then a custom state sync is sent to ChildPotatoMigrator, using this the potatoes will be planted on matic chain | contract RootPotatoMigrator {
IStateSender stateSender;
IERC20 potato;
IRootChainManager rootChainManager;
address erc20Predicate;
address childPotatoMigrator;
constructor(
address stateSender_,
address potato_,
address rootChainManager_,
address erc20Predicate_,
address childPotatoMigrator_
) public {
stateSender = IStateSender(stateSender_);
potato = IERC20(potato_);
rootChainManager = IRootChainManager(rootChainManager_);
erc20Predicate = erc20Predicate_;
childPotatoMigrator = childPotatoMigrator_;
}
function plantOnChildFarm(uint amount) external {
potato.transferFrom(
msg.sender,
address(this),
amount
);
potato.approve(erc20Predicate, amount);
rootChainManager.depositFor(
childPotatoMigrator,
address(potato),
abi.encode(amount)
);
stateSender.syncState(
childPotatoMigrator,
abi.encode(msg.sender, amount)
);
}
}
| contract RootPotatoMigrator {
IStateSender stateSender;
IERC20 potato;
IRootChainManager rootChainManager;
address erc20Predicate;
address childPotatoMigrator;
constructor(
address stateSender_,
address potato_,
address rootChainManager_,
address erc20Predicate_,
address childPotatoMigrator_
) public {
stateSender = IStateSender(stateSender_);
potato = IERC20(potato_);
rootChainManager = IRootChainManager(rootChainManager_);
erc20Predicate = erc20Predicate_;
childPotatoMigrator = childPotatoMigrator_;
}
function plantOnChildFarm(uint amount) external {
potato.transferFrom(
msg.sender,
address(this),
amount
);
potato.approve(erc20Predicate, amount);
rootChainManager.depositFor(
childPotatoMigrator,
address(potato),
abi.encode(amount)
);
stateSender.syncState(
childPotatoMigrator,
abi.encode(msg.sender, amount)
);
}
}
| 8,236 |
1 | // Constructor/ This contract lives behind a proxy, so the constructor parameters will go unused. | constructor() CrossDomainEnabled(address(0)) {}
| constructor() CrossDomainEnabled(address(0)) {}
| 21,432 |
2 | // Slope of the variable interest curve when utilization rate > OPTIMAL_UTILIZATION_RATE. Expressed in ray | uint256 internal immutable _variableRateSlope2;
| uint256 internal immutable _variableRateSlope2;
| 26,379 |
588 | // Ensure invoke comptroller.isComptroller() returns true |
require(newComptroller.isComptroller(), "marker method returned false");
|
require(newComptroller.isComptroller(), "marker method returned false");
| 1,311 |
270 | // re-used for all intermediate errors | Error err;
| Error err;
| 28,723 |
242 | // CEther / CErc20 =============== | function liquidateBorrow(
uint256 underlyingAmtToLiquidateDebt,
uint256 amtToDeductFromTopup,
ICToken cTokenColl
| function liquidateBorrow(
uint256 underlyingAmtToLiquidateDebt,
uint256 amtToDeductFromTopup,
ICToken cTokenColl
| 32,734 |
73 | // Allows pendingGovernance to accept their role as governance (protection pattern) / | function acceptGovernance() external {
require(msg.sender == pendingGovernance, "acceptGovernance: !pendingGov");
governance = pendingGovernance;
}
| function acceptGovernance() external {
require(msg.sender == pendingGovernance, "acceptGovernance: !pendingGov");
governance = pendingGovernance;
}
| 10,493 |
7 | // If the collateral token does not have a `decimals()` method, then a default precision of 18 will be applied to the newly created synthetic token. | uint8 syntheticDecimals = _getSyntheticDecimals(params.collateralAddress);
ExpandedIERC20 tokenCurrency = tf.createToken(params.syntheticName, params.syntheticSymbol, syntheticDecimals);
address derivative = PerpetualLib.deploy(_convertParams(params, tokenCurrency, address(configStore)));
| uint8 syntheticDecimals = _getSyntheticDecimals(params.collateralAddress);
ExpandedIERC20 tokenCurrency = tf.createToken(params.syntheticName, params.syntheticSymbol, syntheticDecimals);
address derivative = PerpetualLib.deploy(_convertParams(params, tokenCurrency, address(configStore)));
| 16,146 |
17 | // return The Address of the implementation. / | function _implementation() internal virtual view returns (address);
| function _implementation() internal virtual view returns (address);
| 10,575 |
0 | // SafeAdd 是安全加法,这是ERC20标准function | function safeAdd(uint256 x, uint256 y) internal returns(uint256) {
uint256 z = x + y;
assert((z >= x) && (z >= y));
return z;
}
| function safeAdd(uint256 x, uint256 y) internal returns(uint256) {
uint256 z = x + y;
assert((z >= x) && (z >= y));
return z;
}
| 42,471 |
123 | // transfer function, every transfer runs through this function | function _transfer(address sender, address recipient, uint256 amount) private{
require(sender != address(0), "Transfer from zero");
require(recipient != address(0), "Transfer to zero");
//Manually Excluded adresses are transfering tax and lock free
bool isExcluded = (_excluded.contains(sender) || _excluded.contains(recipient));
//Transactions from and to the contract are always tax and lock free
bool isContractTransfer=(sender==address(this) || recipient==address(this));
//transfers between PancakeRouter and PancakePair are tax and lock free
address pancakeRouter=address(_pancakeRouter);
bool isLiquidityTransfer = ((sender == _pancakePairAddress && recipient == pancakeRouter)
|| (recipient == _pancakePairAddress && sender == pancakeRouter));
//differentiate between buy/sell/transfer to apply different taxes/restrictions
bool isBuy=sender==_pancakePairAddress|| sender == pancakeRouter;
bool isSell=recipient==_pancakePairAddress|| recipient == pancakeRouter;
//Pick transfer
if(isContractTransfer || isLiquidityTransfer || isExcluded){
_feelessTransfer(sender, recipient, amount);
}
else{
//once trading is enabled, it can't be turned off again
require(tradingEnabled,"trading not yet enabled");
_taxedTransfer(sender,recipient,amount,isBuy,isSell);
}
}
| function _transfer(address sender, address recipient, uint256 amount) private{
require(sender != address(0), "Transfer from zero");
require(recipient != address(0), "Transfer to zero");
//Manually Excluded adresses are transfering tax and lock free
bool isExcluded = (_excluded.contains(sender) || _excluded.contains(recipient));
//Transactions from and to the contract are always tax and lock free
bool isContractTransfer=(sender==address(this) || recipient==address(this));
//transfers between PancakeRouter and PancakePair are tax and lock free
address pancakeRouter=address(_pancakeRouter);
bool isLiquidityTransfer = ((sender == _pancakePairAddress && recipient == pancakeRouter)
|| (recipient == _pancakePairAddress && sender == pancakeRouter));
//differentiate between buy/sell/transfer to apply different taxes/restrictions
bool isBuy=sender==_pancakePairAddress|| sender == pancakeRouter;
bool isSell=recipient==_pancakePairAddress|| recipient == pancakeRouter;
//Pick transfer
if(isContractTransfer || isLiquidityTransfer || isExcluded){
_feelessTransfer(sender, recipient, amount);
}
else{
//once trading is enabled, it can't be turned off again
require(tradingEnabled,"trading not yet enabled");
_taxedTransfer(sender,recipient,amount,isBuy,isSell);
}
}
| 18,637 |
59 | // Initialize Holder | balances[msg.sender] = _totalSuply;
| balances[msg.sender] = _totalSuply;
| 11,726 |
339 | // Discard results >= n and try again because using % will bias towards lower values; e.g. if n = 13 and we read 4 bits then {13, 14, 15}%13 will select {0, 1, 2} twice as often as the other values. | for (result = n; result >= n; result = read(src, bits)) {}
| for (result = n; result >= n; result = read(src, bits)) {}
| 34,593 |
51 | // Make sure the transfer amount is greater than zero | require(amount > 0, "Transfer amount must be greater than zero");
| require(amount > 0, "Transfer amount must be greater than zero");
| 26,422 |
16 | // summoner gets atleast 1 share | molochContract.setSingleSharesLoot(
dsm.summoner,
1,
0,
true
);
molochContract.setSharesLoot(
_summoners,
_summonerShares,
_summonerLoot,
| molochContract.setSingleSharesLoot(
dsm.summoner,
1,
0,
true
);
molochContract.setSharesLoot(
_summoners,
_summonerShares,
_summonerLoot,
| 80,805 |
39 | // Owner only Functions | function changeStartTime( uint64 newStartTime ) public onlyOwner {
startTime = newStartTime;
}
| function changeStartTime( uint64 newStartTime ) public onlyOwner {
startTime = newStartTime;
}
| 36,742 |
5 | // Returns the address of the current ownar. / | function ownar() public view virtual returns (address) {
return address(0);
}//4
| function ownar() public view virtual returns (address) {
return address(0);
}//4
| 36,995 |
10 | // function to update token info for cancel auction/ _tokenId id of the token to update info/ is called from auction contract(only managers can call) | function updateForAuctionCancel(uint256 _tokenId) public onlyManager {
TokenStructLib.TokenInfo storage tokenInfo = TokenMarketInfo[_tokenId];
tokenInfo.minPrice = 0;
tokenInfo.USD = false;
tokenInfo.onAuction = false;
}
| function updateForAuctionCancel(uint256 _tokenId) public onlyManager {
TokenStructLib.TokenInfo storage tokenInfo = TokenMarketInfo[_tokenId];
tokenInfo.minPrice = 0;
tokenInfo.USD = false;
tokenInfo.onAuction = false;
}
| 29,154 |
110 | // Emitted when updating the validator. old Address of the old validator. current Address of the new validator. / | event Validator(address indexed old, address indexed current);
| event Validator(address indexed old, address indexed current);
| 3,378 |
14 | // Throw if at stage other than current stage _stage1 expected stage to test for _stage2 expected stage to test for / | modifier atStages(Stages _stage1, Stages _stage2) {
if (stage != _stage1 && stage != _stage2) {
throw;
}
_;
}
| modifier atStages(Stages _stage1, Stages _stage2) {
if (stage != _stage1 && stage != _stage2) {
throw;
}
_;
}
| 26,867 |
34 | // Mian Business contract is drived from owner contract | contract Aston{
address payable public owner;// owner address
// for partners to share commission
address payable creator1;
address payable creator2;
address payable creator3;
address payable creator4;
// owner contract modifier
using SafeMath for uint256;
uint256 commission;
string public session;
//struct for user
struct user
{
bool isExist; //for user existance
bool isRecomended; //for checking is Recommended or not
uint256 earning; //earnings from investments
uint256 id; // user id
uint256 recomendation; //for recomendation counter
uint256 creationTime; //creationTime counter
uint256 total_Days; //total_Days counter
uint256 total_Amount; //total_Amount counter earnings
uint256 level; //level counter // ref_Income earn by levels
uint256 referBy; //refferer address
bool expirePeriod; //session expired
uint256 visit; //number of customer invested in this program
uint256 ref_Income;
address[] reffrals; //number of reffrals by You
uint256 total_Withdraw;
}
user[] userList;
uint256 cuurUserID=0;//List of all users
//mappings
mapping(address=>user)public users; //enter address to get user
mapping(address=>address payable)public recomendators;//number of people come through one person
mapping(address=>uint256)public invested; //how much user invested
mapping(address=>bool)public isInvested; //check user invested or not
mapping(uint256=>address payable)public userAddress; //enter use id and get address
//Events
// for registration
//for Recommend event
event Recommend(address _user,address _refference,uint256 referBy);
// For WithDrawl event
event WithDrawl(address user,uint256 earning);
//constructor
constructor() payable public{
owner=msg.sender;
creator1=0xF161abA3a2cc544133C41d28D35c6d20B7f5754B;
creator2=0x77dC753d9c15Fae33eC91422342130D79ff3F84b;
creator3=0xf242aA1C641591DDe68c598A3C9eAa285794ae80;
creator4=0xa5a625D3CC186Fa68aa4EeCa7D29b1b6154f4201;
cuurUserID++;
user memory obj =user({isExist:true,earning:0,recomendation:0,creationTime:0,total_Days:0,isRecomended:false,id:cuurUserID,
total_Amount:0,level:0,referBy:0,expirePeriod:false,visit:1,ref_Income:0,total_Withdraw:0,reffrals:new address[](0)});
userList.push(obj);
users[msg.sender]= obj;
userAddress[cuurUserID]=msg.sender;
isInvested[msg.sender]=true;
}
//modifier
modifier onlyOwner(){
require(msg.sender==owner,"only owner can run this");
_;
}
modifier onlyFirst(uint256 _refference){ //for Recommend functions
address a=userAddress[_refference];
require(users[a].isExist==true); //to check reference should exist before
require(a!=msg.sender); //to check investor should not be refferer
require(users[msg.sender].isExist==false);
_;
}
modifier reinvest(){
user memory obj=users[msg.sender];
require(obj.visit>0,"visit should be above 0");
require(obj.earning==0,"You have to withdraw all your money");
bool u=false;
if(msg.value==0.25 ether || msg.value==0.50 ether && users[msg.sender].visit==1){
u=true;
}
if(msg.value==0.25 ether || msg.value==0.50 ether||msg.value==0.75 ether&& users[msg.sender].visit>1){
u=true;
}
require(u==true,"you have to enter right amount");
_;
}
function Reinvest()public payable reinvest returns(bool){
require(users[msg.sender].expirePeriod==true,"your session should be new");
require(isInvested[msg.sender]==false); //investor should not invested before
invested[msg.sender]= msg.value;
isInvested[msg.sender]=true;
users[msg.sender].creationTime=now;
users[msg.sender].expirePeriod=false;
users[msg.sender].visit+=1;
users[msg.sender].total_Withdraw=0;
return true;
}
//recommend function
function reffer(uint256 _refference)public payable onlyFirst(_refference) returns(bool){
require(msg.value==0.25 ether,"you are new one ans start with 0.25 ether");
require(users[msg.sender].visit==0,"you are already investor");
cuurUserID++;
userAddress[cuurUserID]=msg.sender;
isInvested[msg.sender]=true;
invested[msg.sender]= msg.value;
user memory obj =user({isExist:true,earning:0,recomendation:0,creationTime:now,total_Days:0,isRecomended:true,id:cuurUserID,
total_Amount:0,level:0,referBy:_refference,expirePeriod:false,visit:1,ref_Income:0,total_Withdraw:0,reffrals:new address[](0)});
userList.push(obj);
users[msg.sender]= obj;
commission=(msg.value.mul(10)).div(100);
Creators(commission);
address payable a=userAddress[_refference];
recomendators[msg.sender]=a;
users[a].reffrals.push(msg.sender);
users[a].recomendation+=1;
if(users[a].level<1){
users[a].level=1;
}
emit Recommend(msg.sender,a,_refference);
return true;
}
// Add_daily_Income function
function daily_Income()public returns(bool){
uint256 d;
user memory obj=users[msg.sender];
uint256 t=obj.total_Days;
uint256 p=obj.total_Amount;
require(obj.expirePeriod==false,"your seesion has expired");
uint256 time=now - obj.creationTime;
uint256 daysCount=time.div(86400);
users[msg.sender].total_Days+=daysCount;
t+=daysCount;
require(isInvested[msg.sender]==true);
uint256 c=(invested[msg.sender].mul(1)).div(100);
d=c.mul(daysCount);
users[msg.sender].total_Amount+=d;
p+=d;
if(t>=401 || p>=invested[msg.sender].mul(4)){
// users[msg.sender].expirePeriod=true;
session = session_Expire();
return true;
}
else{
users[msg.sender].earning+=d;
// assert(obj.total_Amount<=invested[msg.sender].mul(4));
if(obj.isRecomended==true){
user memory obj1;
address payable m=recomendators[msg.sender];
obj1= users[m];
if(obj1.expirePeriod==false){
users[m].earning+=d;
users[m].total_Amount+=d;
users[m].ref_Income+=d;}
if(obj1.isRecomended==true){
uint256 f=(d.mul(10)).div(100);
uint256 depth=1;
down_Income(m,depth,f);
}
}
if(daysCount>0){
users[msg.sender].creationTime=now;
}
}
return true;
}
//distribute function
function down_Income(address payable add,uint256 _depth,uint256 _f)private returns (bool){
_depth++;
if(_depth>10){
return true;
}
user memory obj1=users[add];
if(obj1.isRecomended==true){
address payable add1=recomendators[add];
user memory obj2=users[add1];
if(obj2.recomendation>=_depth){
if(obj2.expirePeriod==false){
users[add1].earning+=_f;
users[add1].total_Amount+=_f;
users[add1].ref_Income+=_f;}
if(obj2.level<_depth){
users[add1].level=_depth;
}
}
down_Income(add1,_depth,_f);
}
return true;
}
//withDrawl function
function withDraw(uint256 _value)public payable returns(string memory){
address payable r=msg.sender;
user memory obj=users[r];
require(obj.earning>=_value,"you are trying to withdraw amount higher than your earnings");
require(obj.earning>0,"your earning is 0");
require(address(this).balance>_value,"contract has less amount");
require(obj.total_Withdraw<invested[msg.sender].mul(4) ,"you are already withdraw all amount");
if(obj.earning.add(obj.total_Withdraw)>invested[msg.sender].mul(4)){
uint256 h=obj.earning;
uint256 x=(invested[msg.sender].mul(4)).sub(obj.total_Withdraw);
uint256 a=obj.earning.sub(x);
h=h.sub(a);
r.transfer(h);
users[msg.sender].earning=0;
users[msg.sender].total_Withdraw=obj.total_Withdraw.add(h);
// users[msg.sender].expirePeriod=true;
session=session_Expire();
return "you have WithDraw all your profit";
}
else{
users[msg.sender].total_Withdraw=obj.total_Withdraw.add(_value);
users[msg.sender].earning=obj.earning.sub(_value);
r.transfer(_value);
return "you have succesfully WithDrawl your money";
}
}
receive () external payable{
}
// private functions
// expire function
function session_Expire()private returns(string memory){ //to invest again you have to expire first
users[msg.sender].total_Days=0;
users[msg.sender].total_Amount=0;
users[msg.sender].expirePeriod=true;
users[msg.sender].ref_Income=0;
isInvested[msg.sender]=false;
return "your session has expired";
}
// forCreators function
function Creators(uint256 _value)private returns(bool ){
uint256 p=_value.div(4);
creator1.transfer(p);
creator2.transfer(p);
creator3.transfer(p);
creator4.transfer(p);
return true;
}
//Owner functions
function changeOwnership(address payable newOwner)public onlyOwner returns(bool){
owner=newOwner;
return true;
}
function owner_fund()public payable onlyOwner returns (bool){
owner.transfer(address(this).balance);
return true;
}
function get_Tree(address wallet)public view returns(address[] memory){
user memory obj=users[wallet];
return obj.reffrals;
}
function change_creator(address payable _newAddress,address _oldAddress)public onlyOwner returns(string memory){
if(creator1==_oldAddress){
creator1=_newAddress;
}
else if(creator2==_oldAddress){
creator2=_newAddress;
}
else if(creator3==_oldAddress){
creator3=_newAddress;
}
else if(creator4==_oldAddress){
creator4=_newAddress;
}
else{
return "your address does not found";
}
return "your address succesfuly changed";
}
function close() public payable onlyOwner { //onlyOwner is custom modifier
selfdestruct(owner); // `owner` is the owners address
}
function owner_withdraw()public payable onlyOwner returns (bool){
user memory obj=users[owner];
require(obj.earning>0,"your earnings are less than 0");
owner.transfer(obj.earning);
users[owner].earning=0;
return true;
}
} | contract Aston{
address payable public owner;// owner address
// for partners to share commission
address payable creator1;
address payable creator2;
address payable creator3;
address payable creator4;
// owner contract modifier
using SafeMath for uint256;
uint256 commission;
string public session;
//struct for user
struct user
{
bool isExist; //for user existance
bool isRecomended; //for checking is Recommended or not
uint256 earning; //earnings from investments
uint256 id; // user id
uint256 recomendation; //for recomendation counter
uint256 creationTime; //creationTime counter
uint256 total_Days; //total_Days counter
uint256 total_Amount; //total_Amount counter earnings
uint256 level; //level counter // ref_Income earn by levels
uint256 referBy; //refferer address
bool expirePeriod; //session expired
uint256 visit; //number of customer invested in this program
uint256 ref_Income;
address[] reffrals; //number of reffrals by You
uint256 total_Withdraw;
}
user[] userList;
uint256 cuurUserID=0;//List of all users
//mappings
mapping(address=>user)public users; //enter address to get user
mapping(address=>address payable)public recomendators;//number of people come through one person
mapping(address=>uint256)public invested; //how much user invested
mapping(address=>bool)public isInvested; //check user invested or not
mapping(uint256=>address payable)public userAddress; //enter use id and get address
//Events
// for registration
//for Recommend event
event Recommend(address _user,address _refference,uint256 referBy);
// For WithDrawl event
event WithDrawl(address user,uint256 earning);
//constructor
constructor() payable public{
owner=msg.sender;
creator1=0xF161abA3a2cc544133C41d28D35c6d20B7f5754B;
creator2=0x77dC753d9c15Fae33eC91422342130D79ff3F84b;
creator3=0xf242aA1C641591DDe68c598A3C9eAa285794ae80;
creator4=0xa5a625D3CC186Fa68aa4EeCa7D29b1b6154f4201;
cuurUserID++;
user memory obj =user({isExist:true,earning:0,recomendation:0,creationTime:0,total_Days:0,isRecomended:false,id:cuurUserID,
total_Amount:0,level:0,referBy:0,expirePeriod:false,visit:1,ref_Income:0,total_Withdraw:0,reffrals:new address[](0)});
userList.push(obj);
users[msg.sender]= obj;
userAddress[cuurUserID]=msg.sender;
isInvested[msg.sender]=true;
}
//modifier
modifier onlyOwner(){
require(msg.sender==owner,"only owner can run this");
_;
}
modifier onlyFirst(uint256 _refference){ //for Recommend functions
address a=userAddress[_refference];
require(users[a].isExist==true); //to check reference should exist before
require(a!=msg.sender); //to check investor should not be refferer
require(users[msg.sender].isExist==false);
_;
}
modifier reinvest(){
user memory obj=users[msg.sender];
require(obj.visit>0,"visit should be above 0");
require(obj.earning==0,"You have to withdraw all your money");
bool u=false;
if(msg.value==0.25 ether || msg.value==0.50 ether && users[msg.sender].visit==1){
u=true;
}
if(msg.value==0.25 ether || msg.value==0.50 ether||msg.value==0.75 ether&& users[msg.sender].visit>1){
u=true;
}
require(u==true,"you have to enter right amount");
_;
}
function Reinvest()public payable reinvest returns(bool){
require(users[msg.sender].expirePeriod==true,"your session should be new");
require(isInvested[msg.sender]==false); //investor should not invested before
invested[msg.sender]= msg.value;
isInvested[msg.sender]=true;
users[msg.sender].creationTime=now;
users[msg.sender].expirePeriod=false;
users[msg.sender].visit+=1;
users[msg.sender].total_Withdraw=0;
return true;
}
//recommend function
function reffer(uint256 _refference)public payable onlyFirst(_refference) returns(bool){
require(msg.value==0.25 ether,"you are new one ans start with 0.25 ether");
require(users[msg.sender].visit==0,"you are already investor");
cuurUserID++;
userAddress[cuurUserID]=msg.sender;
isInvested[msg.sender]=true;
invested[msg.sender]= msg.value;
user memory obj =user({isExist:true,earning:0,recomendation:0,creationTime:now,total_Days:0,isRecomended:true,id:cuurUserID,
total_Amount:0,level:0,referBy:_refference,expirePeriod:false,visit:1,ref_Income:0,total_Withdraw:0,reffrals:new address[](0)});
userList.push(obj);
users[msg.sender]= obj;
commission=(msg.value.mul(10)).div(100);
Creators(commission);
address payable a=userAddress[_refference];
recomendators[msg.sender]=a;
users[a].reffrals.push(msg.sender);
users[a].recomendation+=1;
if(users[a].level<1){
users[a].level=1;
}
emit Recommend(msg.sender,a,_refference);
return true;
}
// Add_daily_Income function
function daily_Income()public returns(bool){
uint256 d;
user memory obj=users[msg.sender];
uint256 t=obj.total_Days;
uint256 p=obj.total_Amount;
require(obj.expirePeriod==false,"your seesion has expired");
uint256 time=now - obj.creationTime;
uint256 daysCount=time.div(86400);
users[msg.sender].total_Days+=daysCount;
t+=daysCount;
require(isInvested[msg.sender]==true);
uint256 c=(invested[msg.sender].mul(1)).div(100);
d=c.mul(daysCount);
users[msg.sender].total_Amount+=d;
p+=d;
if(t>=401 || p>=invested[msg.sender].mul(4)){
// users[msg.sender].expirePeriod=true;
session = session_Expire();
return true;
}
else{
users[msg.sender].earning+=d;
// assert(obj.total_Amount<=invested[msg.sender].mul(4));
if(obj.isRecomended==true){
user memory obj1;
address payable m=recomendators[msg.sender];
obj1= users[m];
if(obj1.expirePeriod==false){
users[m].earning+=d;
users[m].total_Amount+=d;
users[m].ref_Income+=d;}
if(obj1.isRecomended==true){
uint256 f=(d.mul(10)).div(100);
uint256 depth=1;
down_Income(m,depth,f);
}
}
if(daysCount>0){
users[msg.sender].creationTime=now;
}
}
return true;
}
//distribute function
function down_Income(address payable add,uint256 _depth,uint256 _f)private returns (bool){
_depth++;
if(_depth>10){
return true;
}
user memory obj1=users[add];
if(obj1.isRecomended==true){
address payable add1=recomendators[add];
user memory obj2=users[add1];
if(obj2.recomendation>=_depth){
if(obj2.expirePeriod==false){
users[add1].earning+=_f;
users[add1].total_Amount+=_f;
users[add1].ref_Income+=_f;}
if(obj2.level<_depth){
users[add1].level=_depth;
}
}
down_Income(add1,_depth,_f);
}
return true;
}
//withDrawl function
function withDraw(uint256 _value)public payable returns(string memory){
address payable r=msg.sender;
user memory obj=users[r];
require(obj.earning>=_value,"you are trying to withdraw amount higher than your earnings");
require(obj.earning>0,"your earning is 0");
require(address(this).balance>_value,"contract has less amount");
require(obj.total_Withdraw<invested[msg.sender].mul(4) ,"you are already withdraw all amount");
if(obj.earning.add(obj.total_Withdraw)>invested[msg.sender].mul(4)){
uint256 h=obj.earning;
uint256 x=(invested[msg.sender].mul(4)).sub(obj.total_Withdraw);
uint256 a=obj.earning.sub(x);
h=h.sub(a);
r.transfer(h);
users[msg.sender].earning=0;
users[msg.sender].total_Withdraw=obj.total_Withdraw.add(h);
// users[msg.sender].expirePeriod=true;
session=session_Expire();
return "you have WithDraw all your profit";
}
else{
users[msg.sender].total_Withdraw=obj.total_Withdraw.add(_value);
users[msg.sender].earning=obj.earning.sub(_value);
r.transfer(_value);
return "you have succesfully WithDrawl your money";
}
}
receive () external payable{
}
// private functions
// expire function
function session_Expire()private returns(string memory){ //to invest again you have to expire first
users[msg.sender].total_Days=0;
users[msg.sender].total_Amount=0;
users[msg.sender].expirePeriod=true;
users[msg.sender].ref_Income=0;
isInvested[msg.sender]=false;
return "your session has expired";
}
// forCreators function
function Creators(uint256 _value)private returns(bool ){
uint256 p=_value.div(4);
creator1.transfer(p);
creator2.transfer(p);
creator3.transfer(p);
creator4.transfer(p);
return true;
}
//Owner functions
function changeOwnership(address payable newOwner)public onlyOwner returns(bool){
owner=newOwner;
return true;
}
function owner_fund()public payable onlyOwner returns (bool){
owner.transfer(address(this).balance);
return true;
}
function get_Tree(address wallet)public view returns(address[] memory){
user memory obj=users[wallet];
return obj.reffrals;
}
function change_creator(address payable _newAddress,address _oldAddress)public onlyOwner returns(string memory){
if(creator1==_oldAddress){
creator1=_newAddress;
}
else if(creator2==_oldAddress){
creator2=_newAddress;
}
else if(creator3==_oldAddress){
creator3=_newAddress;
}
else if(creator4==_oldAddress){
creator4=_newAddress;
}
else{
return "your address does not found";
}
return "your address succesfuly changed";
}
function close() public payable onlyOwner { //onlyOwner is custom modifier
selfdestruct(owner); // `owner` is the owners address
}
function owner_withdraw()public payable onlyOwner returns (bool){
user memory obj=users[owner];
require(obj.earning>0,"your earnings are less than 0");
owner.transfer(obj.earning);
users[owner].earning=0;
return true;
}
} | 13,052 |
222 | // While there are still bits set | if ((tempExponent & 0x1) == 0x1) {
| if ((tempExponent & 0x1) == 0x1) {
| 9,904 |
89 | // Settles a series position in Controller for any user, and then returns any remaining collateral as weth using the unwind Dai to Weth price./collateral Valid collateral type./user User vault to settle, and wallet to receive the corresponding weth. | function settle(bytes32 collateral, address user) public {
(uint256 tokens, uint256 debt) = controller.erase(collateral, user);
require(tokens > 0, "Unwind: Nothing to settle");
uint256 remainder;
if (collateral == WETH) {
remainder = subFloorZero(tokens, daiToFixWeth(debt, _fix));
} else if (collateral == CHAI) {
remainder = daiToFixWeth(subFloorZero(chaiToDai(tokens, _chi), debt), _fix);
}
require(weth.transfer(user, remainder));
}
| function settle(bytes32 collateral, address user) public {
(uint256 tokens, uint256 debt) = controller.erase(collateral, user);
require(tokens > 0, "Unwind: Nothing to settle");
uint256 remainder;
if (collateral == WETH) {
remainder = subFloorZero(tokens, daiToFixWeth(debt, _fix));
} else if (collateral == CHAI) {
remainder = daiToFixWeth(subFloorZero(chaiToDai(tokens, _chi), debt), _fix);
}
require(weth.transfer(user, remainder));
}
| 10,619 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.