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
8
// KO account which can receive commission
address public koCommissionAccount;
address public koCommissionAccount;
2,861
1,083
// For internal usage in the logic of the parent contracts /
function _getUnderlyingAssetAddress() internal view override returns (address) { return _underlyingAsset; }
function _getUnderlyingAssetAddress() internal view override returns (address) { return _underlyingAsset; }
39,520
86
// Update % lock for LP
function locklpUpdate(uint256 _newlplock) public onlyAuthorized { PERCENT_FOR_LP = _newlplock; }
function locklpUpdate(uint256 _newlplock) public onlyAuthorized { PERCENT_FOR_LP = _newlplock; }
13,442
187
// Store the `operator`.
mstore(0x3a, operator)
mstore(0x3a, operator)
2,574
165
// get the colors for the prism
prismCols = ColorUtils.getColForPrism( tokenHash, geomVars.trisFront[i], subScheme, meanExtents );
prismCols = ColorUtils.getColForPrism( tokenHash, geomVars.trisFront[i], subScheme, meanExtents );
71,979
27
// Asserts are used to use static analysis to find bugs in your code. They should never fail
assert(balanceOf[msg.sender] + balanceOf[_to] == previousBalances); return true;
assert(balanceOf[msg.sender] + balanceOf[_to] == previousBalances); return true;
56,984
73
// the duration of the timed period
uint256 public duration; event DurationUpdate(uint256 _duration); event TimerReset(uint256 _startTime);
uint256 public duration; event DurationUpdate(uint256 _duration); event TimerReset(uint256 _startTime);
3,595
0
// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import {TLCreator} from "tl-creator-contracts/TLCreator.sol"; contract Gaia is TLCreator { constructor( address defaultRoyaltyRecipient, uint256 defaultRoyaltyPercentage, address[] memory admins, bool enableStory, address blockListRegistry ) TLCreator( 0x154DAc76755d2A372804a9C409683F2eeFa9e5e9, "GAIA", "GAIA", defaultRoyaltyRecipient, defaultRoyaltyPercentage, msg.sender, admins, enableStory, blockListRegistry ) {} }
import {TLCreator} from "tl-creator-contracts/TLCreator.sol"; contract Gaia is TLCreator { constructor( address defaultRoyaltyRecipient, uint256 defaultRoyaltyPercentage, address[] memory admins, bool enableStory, address blockListRegistry ) TLCreator( 0x154DAc76755d2A372804a9C409683F2eeFa9e5e9, "GAIA", "GAIA", defaultRoyaltyRecipient, defaultRoyaltyPercentage, msg.sender, admins, enableStory, blockListRegistry ) {} }
31,658
14
// authorize an ERC20 token as one of the collaterals supported by USDs mint/redeem _collateralAddr ERC20 address to be authorized _defaultStrategyAddr strategy address of which the collateral is allocated into on allocate() _allocationAllowed if allocate() is allowed on this collateral _allocatePercentage ideally after allocate(), _allocatePercentage% of the collateral is in strategy, (100 - _allocatePercentage)% in VaultCore _buyBackAddr contract address providing swap function to swap interestEarned to USDsSupply _rebaseAllowed if rebase is allowed on this collateral /
function addCollateral(address _collateralAddr, address _defaultStrategyAddr, bool _allocationAllowed, uint8 _allocatePercentage, address _buyBackAddr, bool _rebaseAllowed) external onlyOwner { require(!collateralsInfo[_collateralAddr].added, "Collateral added"); require(ERC20Upgradeable(_collateralAddr).decimals() <= 18, "Collaterals decimals need to be less than 18"); collateralStruct storage addingCollateral = collateralsInfo[_collateralAddr]; addingCollateral.collateralAddr = _collateralAddr; addingCollateral.added = true; addingCollateral.defaultStrategyAddr = _defaultStrategyAddr; addingCollateral.allocationAllowed = _allocationAllowed; addingCollateral.allocatePercentage = _allocatePercentage; addingCollateral.buyBackAddr = _buyBackAddr; addingCollateral.rebaseAllowed = _rebaseAllowed; allCollateralAddr.push(addingCollateral.collateralAddr); emit CollateralAdded(_collateralAddr, addingCollateral.added, _defaultStrategyAddr, _allocationAllowed, _allocatePercentage, _buyBackAddr, _rebaseAllowed); }
function addCollateral(address _collateralAddr, address _defaultStrategyAddr, bool _allocationAllowed, uint8 _allocatePercentage, address _buyBackAddr, bool _rebaseAllowed) external onlyOwner { require(!collateralsInfo[_collateralAddr].added, "Collateral added"); require(ERC20Upgradeable(_collateralAddr).decimals() <= 18, "Collaterals decimals need to be less than 18"); collateralStruct storage addingCollateral = collateralsInfo[_collateralAddr]; addingCollateral.collateralAddr = _collateralAddr; addingCollateral.added = true; addingCollateral.defaultStrategyAddr = _defaultStrategyAddr; addingCollateral.allocationAllowed = _allocationAllowed; addingCollateral.allocatePercentage = _allocatePercentage; addingCollateral.buyBackAddr = _buyBackAddr; addingCollateral.rebaseAllowed = _rebaseAllowed; allCollateralAddr.push(addingCollateral.collateralAddr); emit CollateralAdded(_collateralAddr, addingCollateral.added, _defaultStrategyAddr, _allocationAllowed, _allocatePercentage, _buyBackAddr, _rebaseAllowed); }
1,674
5
// Initialize new contract/_key the resolver key for this contract/ return _success if the initialization is successful
function init(bytes32 _key, address _resolver) internal returns (bool _success)
function init(bytes32 _key, address _resolver) internal returns (bool _success)
3,859
6
// Get imm's lower 6 bits
(uint64 rs1, int32 imm) = getRs1Imm(mi, insn); uint32 shiftAmount = uint32(imm & int32(RiscVConstants.getXlen() - 1)); return rs1 >> shiftAmount;
(uint64 rs1, int32 imm) = getRs1Imm(mi, insn); uint32 shiftAmount = uint32(imm & int32(RiscVConstants.getXlen() - 1)); return rs1 >> shiftAmount;
50,137
17
// ------------------------------------------------------------------------ Total supply ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; }
function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; }
41,670
216
// Get the current Vault.balance/this is reflexive, a change in the strat will change the balance in the vault
function _getBalance() internal returns (uint256) { ISettV4 vault = ISettV4(IController(controller).vaults(want)); return vault.balance(); }
function _getBalance() internal returns (uint256) { ISettV4 vault = ISettV4(IController(controller).vaults(want)); return vault.balance(); }
15,883
122
// Take a transaction fee
uint256 payment = uint256(SafeMath.div(SafeMath.mul(sellingPrice, 90), 100)); uint256 purchaseExcess = SafeMath.sub(msg.value, sellingPrice); uint256 level = getBagLevel(bag); bag.level = SafeMath.add(level, 1); bag.owner = newOwner; bag.purchasedAt = now;
uint256 payment = uint256(SafeMath.div(SafeMath.mul(sellingPrice, 90), 100)); uint256 purchaseExcess = SafeMath.sub(msg.value, sellingPrice); uint256 level = getBagLevel(bag); bag.level = SafeMath.add(level, 1); bag.owner = newOwner; bag.purchasedAt = now;
60,019
2
// User address => rewards to be claimed
mapping(address => uint) public rewards; mapping(address => uint) public time2fullRedemption; mapping(address => uint) public unstakeRate; mapping(address => uint) public lastWithdrawTime; uint256 immutable exitCycle = 30 days; uint256 public claimAbleTime;
mapping(address => uint) public rewards; mapping(address => uint) public time2fullRedemption; mapping(address => uint) public unstakeRate; mapping(address => uint) public lastWithdrawTime; uint256 immutable exitCycle = 30 days; uint256 public claimAbleTime;
38,137
95
// Sets the stored oracle address _oracle The address of the oracle contract /
function setChainlinkOracle(address _oracle) internal { oracle = ChainlinkRequestInterface(_oracle); }
function setChainlinkOracle(address _oracle) internal { oracle = ChainlinkRequestInterface(_oracle); }
64,420
104
// migrates stake from the LegacyRewardsGenerator (will be called once for each user)/ the rewards multipliers must be set in advance
function migrationStake( address policyBookAddress, uint256 nftIndex, uint256 amount, uint256 currentReward ) external;
function migrationStake( address policyBookAddress, uint256 nftIndex, uint256 amount, uint256 currentReward ) external;
24,513
0
// Override so the openzeppelin tokenURI() method will use this method to create the full tokenURI instead
function _baseURI() internal view virtual override returns (string memory) { return baseTokenURI; }
function _baseURI() internal view virtual override returns (string memory) { return baseTokenURI; }
51,231
110
// Recovers lost tokens for whatever reason by the owner.
function recover(address _token, uint _amount) external onlyOwner { if (_amount == type(uint).max) { _amount = IERC20(_token).balanceOf(address(this)); } IERC20(_token).safeTransfer(msg.sender, _amount); }
function recover(address _token, uint _amount) external onlyOwner { if (_amount == type(uint).max) { _amount = IERC20(_token).balanceOf(address(this)); } IERC20(_token).safeTransfer(msg.sender, _amount); }
59,110
53
// To be updated by contract owner to allow presale minting for a given token /
function setTokenPresaleState( uint256 _tokenId, bool _saleActiveState
function setTokenPresaleState( uint256 _tokenId, bool _saleActiveState
21,297
11
// Request An Issuer Account
function requestIssuerAccount(string memory _Desc, string memory _IssueId) registered(msg.sender) public { require(IssuerDetail[msg.sender].Status == 0, "Either Account is already an Issuer or has a pending issuer request"); issuer memory newIssuer; newIssuer.IssuerAddress = msg.sender; newIssuer.Status = 1; newIssuer.Desc = _Desc; newIssuer.IssueId = _IssueId; newIssuer.ReqCount = 0; IssuerDetail[msg.sender] = newIssuer; //create a verification request issuerVerificationRequest memory NewRequest; NewRequest.Owner = msg.sender; NewRequest.Status = 1; NewRequest.Id = _IssueId; NewRequest.Desc = _Desc; IssuerVerificationRequest.push(NewRequest); }
function requestIssuerAccount(string memory _Desc, string memory _IssueId) registered(msg.sender) public { require(IssuerDetail[msg.sender].Status == 0, "Either Account is already an Issuer or has a pending issuer request"); issuer memory newIssuer; newIssuer.IssuerAddress = msg.sender; newIssuer.Status = 1; newIssuer.Desc = _Desc; newIssuer.IssueId = _IssueId; newIssuer.ReqCount = 0; IssuerDetail[msg.sender] = newIssuer; //create a verification request issuerVerificationRequest memory NewRequest; NewRequest.Owner = msg.sender; NewRequest.Status = 1; NewRequest.Id = _IssueId; NewRequest.Desc = _Desc; IssuerVerificationRequest.push(NewRequest); }
33,355
17
// add delegates to the minter
_moveDelegates(_delegates[to],address(0) , lawValue); emit Transfer(to, address(0), amount);
_moveDelegates(_delegates[to],address(0) , lawValue); emit Transfer(to, address(0), amount);
49,540
41
// equivalent: abi.decode(inputs, (uint256, bytes, address, address, uint256))
uint256 value; address recipient; address token; uint256 id; assembly { value := calldataload(inputs.offset)
uint256 value; address recipient; address token; uint256 id; assembly { value := calldataload(inputs.offset)
24,644
604
// decode a UQ144x112 into a uint144 by truncating after the radix point
function decode144(uq144x112 memory self) internal pure returns (uint144) { return uint144(self._x >> RESOLUTION); }
function decode144(uq144x112 memory self) internal pure returns (uint144) { return uint144(self._x >> RESOLUTION); }
6,382
38
// Sets an auto-compound value for a delegation/ @custom:selector faa1786f/candidate The address of the supported collator candidate/value The percent of reward that should be auto-compounded/candidateAutoCompoundingDelegationCount The number of auto-compounding delegations/ in support of the candidate/delegatorDelegationCount The number of existing delegations by the caller
function setAutoCompound( address candidate, uint8 value, uint256 candidateAutoCompoundingDelegationCount, uint256 delegatorDelegationCount ) external;
function setAutoCompound( address candidate, uint8 value, uint256 candidateAutoCompoundingDelegationCount, uint256 delegatorDelegationCount ) external;
32,327
18
// Approves a recovery.This method is important for when the address is an contract (such as Identity). _secretCall Hash of the recovery call _proof Merkle proof of friendsMerkleRoot with msg.sender /
function approve(bytes32 _secretCall, bytes32[] calldata _proof) external
function approve(bytes32 _secretCall, bytes32[] calldata _proof) external
3,786
14
// Update the given pool's reward setting
function setPoolReward(uint256 _pid, uint256 _tokenPerDaily, bool _isOpenReward, bool _isRewardCet, uint256 _startTime, uint256 _endTime) public onlyOwner { poolInfo[_pid].tokenPerDaily = _tokenPerDaily; poolInfo[_pid].isOpenReward = _isOpenReward; poolInfo[_pid].isRewardCet = _isRewardCet; poolInfo[_pid].startTime = _startTime; poolInfo[_pid].endTime = _endTime; }
function setPoolReward(uint256 _pid, uint256 _tokenPerDaily, bool _isOpenReward, bool _isRewardCet, uint256 _startTime, uint256 _endTime) public onlyOwner { poolInfo[_pid].tokenPerDaily = _tokenPerDaily; poolInfo[_pid].isOpenReward = _isOpenReward; poolInfo[_pid].isRewardCet = _isRewardCet; poolInfo[_pid].startTime = _startTime; poolInfo[_pid].endTime = _endTime; }
381
133
// The total balance of token A in the pool not counting the amortization /
uint256 public deamortizedTokenABalance;
uint256 public deamortizedTokenABalance;
64,105
11
// Function for creating a document and storing it on blockchain
function createDoc(string memory fileName, string memory docType, address docOwner, string memory hash,
function createDoc(string memory fileName, string memory docType, address docOwner, string memory hash,
25,794
234
// Boolean whether the voting round passed or not
bool passed;
bool passed;
53,302
125
// Buy WETH from Uniswap with tokens
uint256 sellBalance = gain.mul(10**tokenList[targetID].decimals).div(1e18); // Convert to target decimals uint256 holdBalance = sellBalance.mul(percentDepositor).div(divisionFactor); sellBalance = sellBalance.sub(holdBalance); // We will buy WETH with this amount if(sellBalance <= tokenList[targetID].token.balanceOf(address(this))){ IERC20 weth = IERC20(router.WETH());
uint256 sellBalance = gain.mul(10**tokenList[targetID].decimals).div(1e18); // Convert to target decimals uint256 holdBalance = sellBalance.mul(percentDepositor).div(divisionFactor); sellBalance = sellBalance.sub(holdBalance); // We will buy WETH with this amount if(sellBalance <= tokenList[targetID].token.balanceOf(address(this))){ IERC20 weth = IERC20(router.WETH());
10,974
8
// IPolicyCore
function createTranche ( uint256 _numShares, uint256 _pricePerShareAmount, uint256[] calldata _premiums ) external override assertCanCreateTranche assertCreatedState
function createTranche ( uint256 _numShares, uint256 _pricePerShareAmount, uint256[] calldata _premiums ) external override assertCanCreateTranche assertCreatedState
23,504
207
// Update liquidities
_total_liquidity_locked = _total_liquidity_locked.add(liquidity); _locked_liquidity[staker_address] = _locked_liquidity[staker_address] .add(liquidity);
_total_liquidity_locked = _total_liquidity_locked.add(liquidity); _locked_liquidity[staker_address] = _locked_liquidity[staker_address] .add(liquidity);
15,154
46
// Returns asset balance for current address of a particular holder._holder holder address. _symbol asset symbol. return holder balance. /
function balanceOf(address _holder, bytes32 _symbol) constant returns(uint) { uint holderId = getHolderId(_holder); return holders[holderId].addr == _holder ? _balanceOf(holderId, _symbol) : 0; }
function balanceOf(address _holder, bytes32 _symbol) constant returns(uint) { uint holderId = getHolderId(_holder); return holders[holderId].addr == _holder ? _balanceOf(holderId, _symbol) : 0; }
29,015
74
// Fallback. wallets utilize to send ether in order to broker trade. /
function () external payable { } /** * External */ /** * @dev Returns the Wallet contract address associated to a user account. If the user account is not known, try to * migrate the wallet address from the old exchange instance. This function is equivalent to getWallet(), in addition * it stores the wallet address fetched from old the exchange instance. * @param userAccount The user account address * @return The address of the Wallet instance associated to the user account */ function retrieveWallet(address userAccount) public returns(address walletAddress) { walletAddress = userAccountToWallet_[userAccount]; if (walletAddress == address(0) && previousExchangeAddress_ != 0) { // Retrieve the wallet address from the old exchange. walletAddress = ExchangeV1(previousExchangeAddress_).userAccountToWallet_(userAccount); // TODO: in the future versions of the exchange the above line must be replaced with the following one //walletAddress = ExchangeV2(previousExchangeAddress_).retrieveWallet(userAccount); if (walletAddress != address(0)) { userAccountToWallet_[userAccount] = walletAddress; } } }
function () external payable { } /** * External */ /** * @dev Returns the Wallet contract address associated to a user account. If the user account is not known, try to * migrate the wallet address from the old exchange instance. This function is equivalent to getWallet(), in addition * it stores the wallet address fetched from old the exchange instance. * @param userAccount The user account address * @return The address of the Wallet instance associated to the user account */ function retrieveWallet(address userAccount) public returns(address walletAddress) { walletAddress = userAccountToWallet_[userAccount]; if (walletAddress == address(0) && previousExchangeAddress_ != 0) { // Retrieve the wallet address from the old exchange. walletAddress = ExchangeV1(previousExchangeAddress_).userAccountToWallet_(userAccount); // TODO: in the future versions of the exchange the above line must be replaced with the following one //walletAddress = ExchangeV2(previousExchangeAddress_).retrieveWallet(userAccount); if (walletAddress != address(0)) { userAccountToWallet_[userAccount] = walletAddress; } } }
11,862
912
// The address of the pending governance.
address public pendingGovernance;
address public pendingGovernance;
5,863
8
// fallback receive
* Emits {CoinReceived} evt */ receive() external payable override { _coin_reserve = getMyCoinBalance(); emit CoinReceived(msg.value); }
* Emits {CoinReceived} evt */ receive() external payable override { _coin_reserve = getMyCoinBalance(); emit CoinReceived(msg.value); }
42,004
157
// Update the total amount participating
if (new_hiiq_balance >= old_hiiq_balance) { uint256 weight_diff = new_hiiq_balance.sub(old_hiiq_balance); totalHiIQParticipating = totalHiIQParticipating.add(weight_diff); } else {
if (new_hiiq_balance >= old_hiiq_balance) { uint256 weight_diff = new_hiiq_balance.sub(old_hiiq_balance); totalHiIQParticipating = totalHiIQParticipating.add(weight_diff); } else {
49,127
9
// Transfer Blocked - Sender not eligible
require(spender != address(0), "zero address");
require(spender != address(0), "zero address");
6,497
2
// encodePacked(AAA, BBB) -> AAABBB encodePacked(AA, ABBB) -> AAABBB
return keccak256(abi.encodePacked(_text, _anotherText));
return keccak256(abi.encodePacked(_text, _anotherText));
43,457
18
// Set paused
function setPaused(bool value) external onlyContractOwner { paused = value; }
function setPaused(bool value) external onlyContractOwner { paused = value; }
2,358
21
// The maximum profit from each bet is 10% of the contract balance.
ownerSetMaxProfitAsPercentOfHouse(10000);
ownerSetMaxProfitAsPercentOfHouse(10000);
77,529
15
// Deploy Airdrop
function DeployAirDrop(bool _status)public isOwner preAirdrop returns(bool){ AirDropStatus = _status; XRC_Contract.transfer(msg.sender,leftToBeAllocated); leftToBeAllocated =0; return AirDropStatus; }
function DeployAirDrop(bool _status)public isOwner preAirdrop returns(bool){ AirDropStatus = _status; XRC_Contract.transfer(msg.sender,leftToBeAllocated); leftToBeAllocated =0; return AirDropStatus; }
10,865
87
// proceed as normal to copy permutation
current_alpha.mul_assign(state.alpha); // alpha^5 PairingsBn254.Fr memory alpha_for_grand_product = PairingsBn254.copy(current_alpha);
current_alpha.mul_assign(state.alpha); // alpha^5 PairingsBn254.Fr memory alpha_for_grand_product = PairingsBn254.copy(current_alpha);
31,295
39
// handle the transfer of reward tokens via `transferFrom` to reduce the number of transactions required and ensure correctness of the _reward amount
IERC20(_rewardsToken).safeTransferFrom(msg.sender, address(this), _reward); emit RewardAdded(_rewardsToken, _reward);
IERC20(_rewardsToken).safeTransferFrom(msg.sender, address(this), _reward); emit RewardAdded(_rewardsToken, _reward);
9,491
52
// The number of memory words this memory view occupies, rounded up. memView The viewreturnuint256 - The number of memory words /
function words(bytes29 memView) internal pure returns (uint256) { return uint256(len(memView)).add(32) / 32; }
function words(bytes29 memView) internal pure returns (uint256) { return uint256(len(memView)).add(32) / 32; }
22,675
164
// Calculate total profit w/o farming
if (debt < currentValue){ _profit = currentValue.sub(debt); } else {
if (debt < currentValue){ _profit = currentValue.sub(debt); } else {
22,009
344
// Calc interest
function collectInterest() external returns (uint256 massetMinted, uint256 newTotalSupply);
function collectInterest() external returns (uint256 massetMinted, uint256 newTotalSupply);
49,274
123
// Internal view function to derive the EIP-712 domain separator. return The derived domain separator. /
function _deriveDomainSeparator() internal view returns (bytes32) { // prettier-ignore return keccak256( abi.encode( _EIP_712_DOMAIN_TYPEHASH, _NAME_HASH, _VERSION_HASH, block.chainid, address(this) ) ); }
function _deriveDomainSeparator() internal view returns (bytes32) { // prettier-ignore return keccak256( abi.encode( _EIP_712_DOMAIN_TYPEHASH, _NAME_HASH, _VERSION_HASH, block.chainid, address(this) ) ); }
38,003
57
// console.log("%s %s %s", _msgSender(), tokenSeller, address(this));
TokenType tokenTypeOfListing = getTokenType(_params.assetContract);
TokenType tokenTypeOfListing = getTokenType(_params.assetContract);
18,908
9
// deposit - refundable - 2value of token
uint256 deposit = 2 * tokenValue; return (deposit + compound);
uint256 deposit = 2 * tokenValue; return (deposit + compound);
51,827
83
// Claim all earned BOOGIE and UNI from all pools. Claiming won't work until boogiePoolActive == true
function claimAll() public { require(boogiePoolActive == true, "boogie pool not active"); uint256 totalPendingBoogieAmount = 0; uint256 length = poolInfo.length; for (uint256 pid = 0; pid < length; ++pid) { UserInfo storage user = userInfo[pid][msg.sender]; if (user.staked > 0) { updatePool(pid); PoolInfo storage pool = poolInfo[pid]; uint256 accBoogiePerShare = pool.accBoogiePerShare; uint256 pendingPoolBoogieRewards = user.staked.mul(accBoogiePerShare).div(1e12).sub(user.rewardDebt); user.claimed += pendingPoolBoogieRewards; totalPendingBoogieAmount = totalPendingBoogieAmount.add(pendingPoolBoogieRewards); user.rewardDebt = user.staked.mul(accBoogiePerShare).div(1e12); } } require(totalPendingBoogieAmount > 0, "nothing to claim"); if (totalPendingBoogieAmount > 0) _safeBoogieTransfer(msg.sender, totalPendingBoogieAmount); emit ClaimAll(msg.sender, totalPendingBoogieAmount, 0); //totalPendingUniAmount }
function claimAll() public { require(boogiePoolActive == true, "boogie pool not active"); uint256 totalPendingBoogieAmount = 0; uint256 length = poolInfo.length; for (uint256 pid = 0; pid < length; ++pid) { UserInfo storage user = userInfo[pid][msg.sender]; if (user.staked > 0) { updatePool(pid); PoolInfo storage pool = poolInfo[pid]; uint256 accBoogiePerShare = pool.accBoogiePerShare; uint256 pendingPoolBoogieRewards = user.staked.mul(accBoogiePerShare).div(1e12).sub(user.rewardDebt); user.claimed += pendingPoolBoogieRewards; totalPendingBoogieAmount = totalPendingBoogieAmount.add(pendingPoolBoogieRewards); user.rewardDebt = user.staked.mul(accBoogiePerShare).div(1e12); } } require(totalPendingBoogieAmount > 0, "nothing to claim"); if (totalPendingBoogieAmount > 0) _safeBoogieTransfer(msg.sender, totalPendingBoogieAmount); emit ClaimAll(msg.sender, totalPendingBoogieAmount, 0); //totalPendingUniAmount }
26,877
162
// each merkle_tree lock component has this form: (locked_amount || expiration_block || secrethash) = 332 bytes
require(length % 96 == 0); uint256 i; uint256 total_unlocked_amount; uint256 unlocked_amount; bytes32 lockhash; bytes32 merkle_root; bytes32[] memory merkle_layer = new bytes32[](length / 96 + 1);
require(length % 96 == 0); uint256 i; uint256 total_unlocked_amount; uint256 unlocked_amount; bytes32 lockhash; bytes32 merkle_root; bytes32[] memory merkle_layer = new bytes32[](length / 96 + 1);
16,967
45
// Updates totalSupply
Burn(msg.sender, _countToBurn); return true;
Burn(msg.sender, _countToBurn); return true;
35,497
195
// Checkpoint function to update a user's withdrawal fees on deposit and redeem from Address sending from to Address sending to amount Amount to redeem or deposit /
function handleLpTokenTransfer( address from, address to, uint256 amount
function handleLpTokenTransfer( address from, address to, uint256 amount
16,360
4
// A modifier which reverts if the caller is not the admin.
modifier onlyAdmin() { require(admin == msg.sender, "YearnVaultAdapter: only admin"); _; }
modifier onlyAdmin() { require(admin == msg.sender, "YearnVaultAdapter: only admin"); _; }
42,234
113
// Amount of token that sender can transfer
uint256 totalTransferableBalance = afterCrowedsaleTokenBalance.add(transferableCrowedSaleToken);
uint256 totalTransferableBalance = afterCrowedsaleTokenBalance.add(transferableCrowedSaleToken);
54,977
15
// Apply the Dampening factor.
supplyDelta = supplyDelta.div(rebaseLag.toInt256Safe()); if (supplyDelta > 0 && oms.totalSupply().add(uint256(supplyDelta)) > MAX_SUPPLY) { supplyDelta = (MAX_SUPPLY.sub(oms.totalSupply())).toInt256Safe(); }
supplyDelta = supplyDelta.div(rebaseLag.toInt256Safe()); if (supplyDelta > 0 && oms.totalSupply().add(uint256(supplyDelta)) > MAX_SUPPLY) { supplyDelta = (MAX_SUPPLY.sub(oms.totalSupply())).toInt256Safe(); }
4,340
165
// Returns if a darknode is refundable. This is true for darknodes/ that have been in the deregistered state for one full epoch.
function isRefundable(address _darknodeID) public view returns (bool) { return isDeregistered(_darknodeID) && store.darknodeDeregisteredAt(_darknodeID) <= previousEpoch.blocknumber; }
function isRefundable(address _darknodeID) public view returns (bool) { return isDeregistered(_darknodeID) && store.darknodeDeregisteredAt(_darknodeID) <= previousEpoch.blocknumber; }
33,823
188
// We ERC-20 transfer the asset into the protocol (note: pre-conditions already checked above)
err = doTransferIn(asset, msg.sender, amount); if (err != Error.NO_ERROR) {
err = doTransferIn(asset, msg.sender, amount); if (err != Error.NO_ERROR) {
37,675
30
// Generate new thing
contract ThingCompute is ThingFactory { modifier onlyOwnerOf(uint _thingId) { require(msg.sender == thingToOwner[_thingId]); _; } function strConcat(string _a, string _b, string _c, string _d, string _e) internal pure returns (string){ bytes memory _ba = bytes(_a); bytes memory _bb = bytes(_b); bytes memory _bc = bytes(_c); bytes memory _bd = bytes(_d); bytes memory _be = bytes(_e); string memory abcde = new string(_ba.length + _bb.length + _bc.length + _bd.length + _be.length); bytes memory babcde = bytes(abcde); uint k = 0; for (uint i = 0; i < _ba.length; i++) babcde[k++] = _ba[i]; for (i = 0; i < _bb.length; i++) babcde[k++] = _bb[i]; for (i = 0; i < _bc.length; i++) babcde[k++] = _bc[i]; for (i = 0; i < _bd.length; i++) babcde[k++] = _bd[i]; for (i = 0; i < _be.length; i++) babcde[k++] = _be[i]; return string(babcde); } function compute(uint _thingId, string func_name, string _targetUrl) public { Thing storage myThing = things[_thingId]; // TODO func_name to func_id _createThing(strConcat("n",myThing.name, "", "", ""), _targetUrl, _thingId, 1, myThing.generation + 1); } }
contract ThingCompute is ThingFactory { modifier onlyOwnerOf(uint _thingId) { require(msg.sender == thingToOwner[_thingId]); _; } function strConcat(string _a, string _b, string _c, string _d, string _e) internal pure returns (string){ bytes memory _ba = bytes(_a); bytes memory _bb = bytes(_b); bytes memory _bc = bytes(_c); bytes memory _bd = bytes(_d); bytes memory _be = bytes(_e); string memory abcde = new string(_ba.length + _bb.length + _bc.length + _bd.length + _be.length); bytes memory babcde = bytes(abcde); uint k = 0; for (uint i = 0; i < _ba.length; i++) babcde[k++] = _ba[i]; for (i = 0; i < _bb.length; i++) babcde[k++] = _bb[i]; for (i = 0; i < _bc.length; i++) babcde[k++] = _bc[i]; for (i = 0; i < _bd.length; i++) babcde[k++] = _bd[i]; for (i = 0; i < _be.length; i++) babcde[k++] = _be[i]; return string(babcde); } function compute(uint _thingId, string func_name, string _targetUrl) public { Thing storage myThing = things[_thingId]; // TODO func_name to func_id _createThing(strConcat("n",myThing.name, "", "", ""), _targetUrl, _thingId, 1, myThing.generation + 1); } }
19,118
92
// Sets the address of the xSEEN ERC-20 staking contract. Emits a StakingAddressChanged event._staking - the address of the staking contract /
function setStaking(address payable _staking) external;
function setStaking(address payable _staking) external;
12,983
25
// System-level Oracle state variables. initialized True if the Oracle has been initialzed. It needs to be initialized on Deployment and re-initialized each Unpause. startSeason The Season the Oracle started minting. Used to ramp up delta b when oracle is first added. balances The cumulative reserve balances of the pool at the start of the Season (used for computing time weighted average delta b). timestamp The timestamp of the start of the current Season. Currently refers to the time weighted average deltaB calculated from the BEAN:3CRV pool. /
struct Oracle { bool initialized; // ────┐ 1 uint32 startSeason; // ──┘ 4 (5/32) uint256[2] balances; uint256 timestamp; }
struct Oracle { bool initialized; // ────┐ 1 uint32 startSeason; // ──┘ 4 (5/32) uint256[2] balances; uint256 timestamp; }
40,659
76
// uint _minusFee = _getFee(_actualAmount);
(outputAmount, fee) = _swapBaseToToken(pool, _actualAmount);
(outputAmount, fee) = _swapBaseToToken(pool, _actualAmount);
30,604
19
// mint the avaiable interests to callee./once it mint, the amount of interests will transfer to callee's address./ return the amount of interests minted.
function mint() external returns (uint256);
function mint() external returns (uint256);
29,766
6
// Allows array of all addresses for certain index to be returned/_index AddressTypes enum of index to be returned/ return address[] memory of addresses from index
function getAddressForType(AddressTypes _index) external view returns (address[] memory);
function getAddressForType(AddressTypes _index) external view returns (address[] memory);
14,092
243
// Removes the gas relay paymaster, withdrawing the remaining WETH balance/ and disabling gas relaying
function shutdownGasRelayPaymaster() external onlyOwnerNotRelayable { IGasRelayPaymaster(gasRelayPaymaster).withdrawBalance(); IVault(vaultProxy).addTrackedAsset(getWethToken()); delete gasRelayPaymaster; emit GasRelayPaymasterSet(address(0)); }
function shutdownGasRelayPaymaster() external onlyOwnerNotRelayable { IGasRelayPaymaster(gasRelayPaymaster).withdrawBalance(); IVault(vaultProxy).addTrackedAsset(getWethToken()); delete gasRelayPaymaster; emit GasRelayPaymasterSet(address(0)); }
25,369
18
// Total reserve value that backs all DVD in circulation./Area below the bonding curve.
uint256 public totalReserve;
uint256 public totalReserve;
10,167
22
// Getter the total number of FYTs on address is delegating _delegator the delegating addressreturn totalDelegated the number of FYTs delegated /
function getTotalDelegated(address _delegator) public view returns (uint256 totalDelegated) { uint256 numberOfDelegations = delegationsByDelegator[_delegator].length; for (uint256 i = 0; i < numberOfDelegations; i++) { totalDelegated = totalDelegated.add(delegationsByDelegator[_delegator][i].delegatedAmount); } }
function getTotalDelegated(address _delegator) public view returns (uint256 totalDelegated) { uint256 numberOfDelegations = delegationsByDelegator[_delegator].length; for (uint256 i = 0; i < numberOfDelegations; i++) { totalDelegated = totalDelegated.add(delegationsByDelegator[_delegator][i].delegatedAmount); } }
5,400
102
// Validate the parameters.
require(rate > 0); require(sharesCap > 0); require(beneficiary != 0x0); require(investor != 0x0); require(token().balanceOf(msg.sender) >= sharesCap);
require(rate > 0); require(sharesCap > 0); require(beneficiary != 0x0); require(investor != 0x0); require(token().balanceOf(msg.sender) >= sharesCap);
804
13
// Adapted from `_transferTokens()` in `Comp.sol` to update delegate votes. hooks into OpenZeppelin's `ERC721._transfer` /
function _beforeTokenTransfer( address from, address to, uint256 tokenId
function _beforeTokenTransfer( address from, address to, uint256 tokenId
7,275
17
// Function to access decimals of token .
function decimals() public view returns (uint8 _decimals) { return decimals; }
function decimals() public view returns (uint8 _decimals) { return decimals; }
559
1,386
// 695
entry "pickapack" : ENG_ADVERB
entry "pickapack" : ENG_ADVERB
21,531
67
// 用户是否是确认者
require(msg.sender == affirm, "Users are not validators"); winValue2 = _num; winTime2 = block.timestamp;
require(msg.sender == affirm, "Users are not validators"); winValue2 = _num; winTime2 = block.timestamp;
17,335
598
// solhint-disable-next-line avoid-low-level-calls
(ok, /* data */) = payoutAddress.call.value(amount)("");
(ok, /* data */) = payoutAddress.call.value(amount)("");
2,086
79
// Transfer seller's premium earned to themself
EIP20Interface token = EIP20Interface(option.premiumInfo.premiumToken); bool success = token.transfer(option.seller, option.premiumInfo.sellerPremium); require(success, "redeemPremium(): premium transfer failed"); emit SellerRedeemedPremium(optionUID, msg.sender);
EIP20Interface token = EIP20Interface(option.premiumInfo.premiumToken); bool success = token.transfer(option.seller, option.premiumInfo.sellerPremium); require(success, "redeemPremium(): premium transfer failed"); emit SellerRedeemedPremium(optionUID, msg.sender);
36,079
96
// transfers crowdsale token from mintable to transferrable state
function releaseTokens() external onlyOwner() // manager is CrowdsaleController instance hasntStopped() // crowdsale wasn't cancelled whenCrowdsaleSuccessful() // crowdsale was successful
function releaseTokens() external onlyOwner() // manager is CrowdsaleController instance hasntStopped() // crowdsale wasn't cancelled whenCrowdsaleSuccessful() // crowdsale was successful
47,115
2
// addresses of other ERC-20s a user has deposited as collateral in this vault
address[] collateralAssets;
address[] collateralAssets;
17,009
40
// emitted when a priority controller is added or removed account address added or removed isPriorityController whether the account is now a priority controller /
event PriorityControllerUpdated(address account, bool isPriorityController);
event PriorityControllerUpdated(address account, bool isPriorityController);
60,515
12
// Development12,000,000 (12%)
uint constant public maxDevSupply = 12000000 * E18;
uint constant public maxDevSupply = 12000000 * E18;
61,257
32
// Ensure we hit our targets.
if (data.side == Side.Sell) {
if (data.side == Side.Sell) {
29,994
10
// Hash of the 10k tops image (run `openssl dgst -sha256 10k_tops.png`)
bytes public constant contentHash = "0x31a9260a4f3b032c13a9b9c11164dcd8ade0f23a70ffcf3f98d1fc9b09e98522"; bytes32 internal _setOfIds; bytes32 internal constant mask = hex"0000000000000000000000000000000000000000000000000000000000003fff"; uint public constant TOKEN_LIMIT = 10000; uint public constant SALE_LIMIT = 9250; uint public constant DEV_MAX = 750; uint public devMints; uint public constant MAX_MINTS_PER_CALL = 20;
bytes public constant contentHash = "0x31a9260a4f3b032c13a9b9c11164dcd8ade0f23a70ffcf3f98d1fc9b09e98522"; bytes32 internal _setOfIds; bytes32 internal constant mask = hex"0000000000000000000000000000000000000000000000000000000000003fff"; uint public constant TOKEN_LIMIT = 10000; uint public constant SALE_LIMIT = 9250; uint public constant DEV_MAX = 750; uint public devMints; uint public constant MAX_MINTS_PER_CALL = 20;
51,429
469
// Adds new MCR data. mcrPMinimum Capital Requirement in percentage. vF Pool fund value in Ether used in the last full daily calculation of the Capital model. onlyDateDate(yyyymmdd) at which MCR details are getting added. /
function addMCRData( uint mcrP, uint mcrE, uint vF, bytes4[] calldata curr, uint[] calldata _threeDayAvg, uint64 onlyDate ) external checkPause
function addMCRData( uint mcrP, uint mcrE, uint vF, bytes4[] calldata curr, uint[] calldata _threeDayAvg, uint64 onlyDate ) external checkPause
2,030
18
// Transporter /
function transporterHandlePackage( address _addr, uint transportertype, address cid
function transporterHandlePackage( address _addr, uint transportertype, address cid
32,201
8
// Token
uint256 bountyAmount = tokenBountyPool[tokenAddress]; uint256 tokenBalance = IERC20(tokenAddress).balanceOf(address(this)); uint256 amountToTransfer = tokenBalance - bountyAmount; require(amountToTransfer > 0, "contract token balance is 0"); IERC20(tokenAddress).approve(address(l2Bridge), amountToTransfer); l2Bridge.regularTransfer( tokenAddress, tokenL1AddressByAddress[tokenAddress],
uint256 bountyAmount = tokenBountyPool[tokenAddress]; uint256 tokenBalance = IERC20(tokenAddress).balanceOf(address(this)); uint256 amountToTransfer = tokenBalance - bountyAmount; require(amountToTransfer > 0, "contract token balance is 0"); IERC20(tokenAddress).approve(address(l2Bridge), amountToTransfer); l2Bridge.regularTransfer( tokenAddress, tokenL1AddressByAddress[tokenAddress],
11,558
10
// Store the `address(this)`.
mstore(0x04, address())
mstore(0x04, address())
3,685
0
// Possible error codes that we can return /
enum MathError { NO_ERROR, DIVISION_BY_ZERO, INTEGER_OVERFLOW, INTEGER_UNDERFLOW }
enum MathError { NO_ERROR, DIVISION_BY_ZERO, INTEGER_OVERFLOW, INTEGER_UNDERFLOW }
23,951
7
// This function should have a fee for quicker withdrawing without waiting
Hodler storage hodler = hodlers[msg.sender]; uint amount = hodler.tokens[token].tokenBalance; hodler.tokens[token].tokenBalance = 0; ERC20Interface(token).approve(msg.sender, amount); ERC20Interface(token).transferFrom(this, msg.sender, amount); emit PanicSell(msg.sender, token, amount, hodler.tokens[token].timeLimit - block.timestamp);
Hodler storage hodler = hodlers[msg.sender]; uint amount = hodler.tokens[token].tokenBalance; hodler.tokens[token].tokenBalance = 0; ERC20Interface(token).approve(msg.sender, amount); ERC20Interface(token).transferFrom(this, msg.sender, amount); emit PanicSell(msg.sender, token, amount, hodler.tokens[token].timeLimit - block.timestamp);
7,174
2
// The maximum gas units the DAO will refund voters on; supports about 9,190 characters
uint256 public constant MAX_REFUND_GAS_USED = 200_000;
uint256 public constant MAX_REFUND_GAS_USED = 200_000;
2,785
127
// store amount and timestamp
vaultData.stakes.push(StakeData(amount, block.timestamp));
vaultData.stakes.push(StakeData(amount, block.timestamp));
6,075
637
// res += valcoefficients[150].
res := addmod(res, mulmod(val, /*coefficients[150]*/ mload(0x1800), PRIME), PRIME)
res := addmod(res, mulmod(val, /*coefficients[150]*/ mload(0x1800), PRIME), PRIME)
21,736
86
// _beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount);
36,054
1
// managers
mapping(address=>bool) public managers;
mapping(address=>bool) public managers;
51,088
190
// Redeem wibBTC for ibBTC. Denominated in shares.
function burn(uint256 _shares) external whenNotPaused onlyApprovedAccount { if (_shares == 0) { return; } _burn(_msgSender(), _shares); require(ibbtc.transfer(_msgSender(), _shares)); }
function burn(uint256 _shares) external whenNotPaused onlyApprovedAccount { if (_shares == 0) { return; } _burn(_msgSender(), _shares); require(ibbtc.transfer(_msgSender(), _shares)); }
26,882
3
// Returns the ABI associated with an ENS node.Defined in EIP205. node The ENS node to query contentTypes A bitwise OR of the ABI formats accepted by the caller.return contentType The content type of the return valuereturn data The ABI data /
function ABI( bytes32 node, uint256 contentTypes
function ABI( bytes32 node, uint256 contentTypes
7,032
20
// borrow borrowableB
bytes memory borrowAData = abi.encode( CalleeData({ callType: CallType.BORROWB, underlying: underlying, borrowableIndex: 0, data: abi.encode( BorrowBCalldata({ borrower: msg.sender, receiver: address(this), borrowAmount: amountB,
bytes memory borrowAData = abi.encode( CalleeData({ callType: CallType.BORROWB, underlying: underlying, borrowableIndex: 0, data: abi.encode( BorrowBCalldata({ borrower: msg.sender, receiver: address(this), borrowAmount: amountB,
51,186
2
// reduces the number of remaining objects by 1 if it Final /
function recordItemRelease(Data storage data) internal { if (data.enable && data.isFinal && data.remainingSupply > 0) data.remainingSupply = SafeMath.sub(data.remainingSupply, 1); }
function recordItemRelease(Data storage data) internal { if (data.enable && data.isFinal && data.remainingSupply > 0) data.remainingSupply = SafeMath.sub(data.remainingSupply, 1); }
1,635
15
// Set target user wins to 0 {onlyACPIMaster}note called after a claimTokens from the parent contract /
function resetAccount(address account) external override onlyACPIMaster returns (bool) { _pendingReturns[account] = 0; _pendingWins[account] = 0; return true; }
function resetAccount(address account) external override onlyACPIMaster returns (bool) { _pendingReturns[account] = 0; _pendingWins[account] = 0; return true; }
7,662
0
// This struct is for the properties of a post.
struct Post{ address owner; string imgHash; string textHash; }
struct Post{ address owner; string imgHash; string textHash; }
8,168
44
// then we check the buy map for the seller
if (_buyMap[from] != 0 && (_buyMap[from] + (12 hours) >= block.timestamp)) {
if (_buyMap[from] != 0 && (_buyMap[from] + (12 hours) >= block.timestamp)) {
82,775