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
11
// STORAGES //A mapping from the owner to their Dinos.
mapping(address => uint256[]) private userOwnedDinos;
mapping(address => uint256[]) private userOwnedDinos;
32,626
89
// Max slippage percent allowed
uint256 public constant MAX_SLIPPAGE_PERCENT = 3000; // 30% IPriceOracleGetter public immutable ORACLE; event Swapped( address indexed fromAsset, address indexed toAsset, uint256 fromAmount, uint256 receivedAmount );
uint256 public constant MAX_SLIPPAGE_PERCENT = 3000; // 30% IPriceOracleGetter public immutable ORACLE; event Swapped( address indexed fromAsset, address indexed toAsset, uint256 fromAmount, uint256 receivedAmount );
21,342
67
// ensure everything is ok before call it
function _removeTokenFrom(address from, uint256 tokenId) internal { uint256 index = tokenIndexs[tokenId]; uint256[] storage tokens = ownerTokens[from]; uint256 indexLast = tokens.length - 1; // save gas // if (index != indexLast) { uint256 tokenIdLast = tokens[indexLast]; tokens[index] = tokenIdLast; tokenIndexs[tokenIdLast] = index; // } tokens.pop(); // delete tokenIndexs[tokenId]; // save gas delete tokenOwners[tokenId]; }
function _removeTokenFrom(address from, uint256 tokenId) internal { uint256 index = tokenIndexs[tokenId]; uint256[] storage tokens = ownerTokens[from]; uint256 indexLast = tokens.length - 1; // save gas // if (index != indexLast) { uint256 tokenIdLast = tokens[indexLast]; tokens[index] = tokenIdLast; tokenIndexs[tokenIdLast] = index; // } tokens.pop(); // delete tokenIndexs[tokenId]; // save gas delete tokenOwners[tokenId]; }
5,485
62
// A limit set so we don't run out of gas
if (i >= borrowDepth) { break; }
if (i >= borrowDepth) { break; }
32,967
18
// WARNING: Adding requireContractRunStateActive modifier will result in contract lockout
requireContractAdmin // Administrator Role block is required to ensure only authorized individuals can pause contract
requireContractAdmin // Administrator Role block is required to ensure only authorized individuals can pause contract
25,440
231
// Increases the max supply for the provided `dmmTokenId` by `amount`. This call reverts with INSUFFICIENT_COLLATERAL if there isn't enough collateral in the Chainlink contract to cover the controller's requirements for minimum collateral. /
function increaseTotalSupply(uint dmmTokenId, uint amount) external;
function increaseTotalSupply(uint dmmTokenId, uint amount) external;
6,263
250
// -----------------------------------------------------------------------/ Validation/ -----------------------------------------------------------------------
bytes32 incentiveId = key.compute();
bytes32 incentiveId = key.compute();
8,975
79
// increase hard cap if previous dont sold out/
function increaseHardCap(uint _amount) external onlyOwner { require(_amount <= 300000000000000000000000000); // presale hard cap hardCap = hardCap.add(_amount); remain = remain.add(_amount); IncreaseHardCap(_amount); }
function increaseHardCap(uint _amount) external onlyOwner { require(_amount <= 300000000000000000000000000); // presale hard cap hardCap = hardCap.add(_amount); remain = remain.add(_amount); IncreaseHardCap(_amount); }
20,409
220
// Join the pool by depositing tokens amount amount of token to deposit /
function join(uint256 amount) external override joiningNotPaused { uint256 fee = amount.mul(joiningFee).div(BASIS_PRECISION); uint256 mintedAmount = mint(amount.sub(fee)); claimableFees = claimableFees.add(fee); // TODO: tx.origin will be depricated in a future ethereum upgrade latestJoinBlock[tx.origin] = block.number; token.safeTransferFrom(msg.sender, address(this), amount); emit Joined(msg.sender, amount, mintedAmount); }
function join(uint256 amount) external override joiningNotPaused { uint256 fee = amount.mul(joiningFee).div(BASIS_PRECISION); uint256 mintedAmount = mint(amount.sub(fee)); claimableFees = claimableFees.add(fee); // TODO: tx.origin will be depricated in a future ethereum upgrade latestJoinBlock[tx.origin] = block.number; token.safeTransferFrom(msg.sender, address(this), amount); emit Joined(msg.sender, amount, mintedAmount); }
43,265
597
// Reads the int72 at `mPtr` in memory.
function readInt72(MemoryPointer mPtr) internal pure returns (int72 value) { assembly { value := mload(mPtr) } }
function readInt72(MemoryPointer mPtr) internal pure returns (int72 value) { assembly { value := mload(mPtr) } }
12,915
97
// Constructor function for the proxy contract._uniswapRouterAddress of the UniswapV2 contract._nyanV2Address of the Nyan-2 contract._nyanV2LPAddress of the Nyan-2 LP token contract._voteDivCatnip fee per vote./
function votingConstructor(address _uniswapRouter, address _nyanV2, address _nyanV2LP, uint256 _requiredVoteCount, uint256 _voteDiv) public { require(!initialized, "The contract has been initialized"); owner = msg.sender; uniswapRouter = _uniswapRouter; currentVotingStartBlock = block.number; currentVotingEndBlock = block.number.add(votingPeriodBlockLength); nyanV2 = _nyanV2; nyanV2LP = _nyanV2LP; isDistributing = false; canDistribute = true; voteDiv = _voteDiv; votePropogationBlocks = 6500; lastVotePropogationBlock = block.number; requiredVoteCount = _requiredVoteCount; initialized = true; }
function votingConstructor(address _uniswapRouter, address _nyanV2, address _nyanV2LP, uint256 _requiredVoteCount, uint256 _voteDiv) public { require(!initialized, "The contract has been initialized"); owner = msg.sender; uniswapRouter = _uniswapRouter; currentVotingStartBlock = block.number; currentVotingEndBlock = block.number.add(votingPeriodBlockLength); nyanV2 = _nyanV2; nyanV2LP = _nyanV2LP; isDistributing = false; canDistribute = true; voteDiv = _voteDiv; votePropogationBlocks = 6500; lastVotePropogationBlock = block.number; requiredVoteCount = _requiredVoteCount; initialized = true; }
26,391
9
// Allow the deployer to change the smart contract meta-data.
function setContractDataURI(string memory _contractDataURI) public onlyOwner { contractDataURI = _contractDataURI; }
function setContractDataURI(string memory _contractDataURI) public onlyOwner { contractDataURI = _contractDataURI; }
226
485
// name(): returns the name of a collection of points
function name() external view returns (string)
function name() external view returns (string)
51,334
105
// Update the PriceFeed Address/_priceFeedAddress PriceFeed Contract Address
function updatePriceFeedAddress(address _priceFeedAddress) external onlyOwner
function updatePriceFeedAddress(address _priceFeedAddress) external onlyOwner
26,996
61
// function to update stakeDays._stakeDays, updated Days . /
function updatestakeDays(uint256 _stakeDays) public onlyOwner { stakeDays = _stakeDays; }
function updatestakeDays(uint256 _stakeDays) public onlyOwner { stakeDays = _stakeDays; }
43,619
23
// internal low level function for deposit funds
function _deposit(address _funder, uint256 _amount) internal { balanceOf[_funder] = balanceOf[_funder].add(_amount); emit Deposit(_funder, _amount); }
function _deposit(address _funder, uint256 _amount) internal { balanceOf[_funder] = balanceOf[_funder].add(_amount); emit Deposit(_funder, _amount); }
13,398
65
// Used to convert weth to eth upon withdraw
interface WrappedEther { function withdraw(uint) external; }
interface WrappedEther { function withdraw(uint) external; }
21,895
133
// Uint8 values
self.claimData.paymentModifier = _uint8Values[0]; return true;
self.claimData.paymentModifier = _uint8Values[0]; return true;
34,937
75
// Update the invariant with the balances the Pool will have after the exit, in order to compute the protocol swap fees due in future joins and exits.
_mutateAmounts(balances, amountsOut, FixedPoint.sub); _lastInvariant = WeightedMath._calculateInvariant(normalizedWeights, balances); return (bptAmountIn, amountsOut, dueProtocolFeeAmounts);
_mutateAmounts(balances, amountsOut, FixedPoint.sub); _lastInvariant = WeightedMath._calculateInvariant(normalizedWeights, balances); return (bptAmountIn, amountsOut, dueProtocolFeeAmounts);
5,519
6
// add indexes an element then adds it to a list value is a bytes32 valuereturn true if value is added successfully /
function add( bytes32 value ) external returns(bool)
function add( bytes32 value ) external returns(bool)
5,273
4
// Gets child of ThereValTestT(ThereValTestT,a). /
function getChildThereValTestT(bytes[] memory _inputs, bytes[] memory challengeInputs) private view returns (types.Property memory) { bytes[] memory forAllSuchThatInputs = new bytes[](3); bytes[] memory notInputs = new bytes[](1); types.Property memory inputPredicateProperty = abi.decode(_inputs[0], (types.Property)); bytes[] memory childInputsOf = new bytes[](inputPredicateProperty.inputs.length + 1); for(uint256 i = 0;i < inputPredicateProperty.inputs.length;i++) { childInputsOf[i] = inputPredicateProperty.inputs[i]; } childInputsOf[inputPredicateProperty.inputs.length] = challengeInputs[0]; notInputs[0] = abi.encode(types.Property({ predicateAddress: inputPredicateProperty.predicateAddress, inputs: childInputsOf })); forAllSuchThatInputs[0] = bytes(""); forAllSuchThatInputs[1] = bytes("b"); forAllSuchThatInputs[2] = abi.encode(types.Property({ predicateAddress: notAddress, inputs: notInputs })); return types.Property({ predicateAddress: forAllSuchThatAddress, inputs: forAllSuchThatInputs }); }
function getChildThereValTestT(bytes[] memory _inputs, bytes[] memory challengeInputs) private view returns (types.Property memory) { bytes[] memory forAllSuchThatInputs = new bytes[](3); bytes[] memory notInputs = new bytes[](1); types.Property memory inputPredicateProperty = abi.decode(_inputs[0], (types.Property)); bytes[] memory childInputsOf = new bytes[](inputPredicateProperty.inputs.length + 1); for(uint256 i = 0;i < inputPredicateProperty.inputs.length;i++) { childInputsOf[i] = inputPredicateProperty.inputs[i]; } childInputsOf[inputPredicateProperty.inputs.length] = challengeInputs[0]; notInputs[0] = abi.encode(types.Property({ predicateAddress: inputPredicateProperty.predicateAddress, inputs: childInputsOf })); forAllSuchThatInputs[0] = bytes(""); forAllSuchThatInputs[1] = bytes("b"); forAllSuchThatInputs[2] = abi.encode(types.Property({ predicateAddress: notAddress, inputs: notInputs })); return types.Property({ predicateAddress: forAllSuchThatAddress, inputs: forAllSuchThatInputs }); }
14,329
9
// Withdraw an already deposited amount if the funds are available tokenId The NFT representing the position amount The amount to withdraw (must be <= interest+principal currently available to withdraw)return interestWithdrawn The interest amount that was withdrawnreturn principalWithdrawn The principal amount that was withdrawn /
function withdraw(uint256 tokenId, uint256 amount) public override nonReentrant whenNotPaused returns (uint256 interestWithdrawn, uint256 principalWithdrawn)
function withdraw(uint256 tokenId, uint256 amount) public override nonReentrant whenNotPaused returns (uint256 interestWithdrawn, uint256 principalWithdrawn)
42,548
0
// Information for a node in the list
struct Node { bool exists; address nextId; // Id of next node (smaller NICR) in the list address prevId; // Id of previous node (larger NICR) in the list }
struct Node { bool exists; address nextId; // Id of next node (smaller NICR) in the list address prevId; // Id of previous node (larger NICR) in the list }
8,835
687
// console.log(symbol(), from, "->", to); console.log(symbol(), ">", amount);
super._beforeTokenTransfer(from, to, amount);
super._beforeTokenTransfer(from, to, amount);
3,650
2
// Address of the seller where funds are collected
address public seller;
address public seller;
3,119
25
// First use funds to try to repay Dai borrow balance.
uint256 remainingDai = _repayOnCompound(AssetType.DAI, daiBalance);
uint256 remainingDai = _repayOnCompound(AssetType.DAI, daiBalance);
26,653
182
// Require a nonzero amount to be filled
require(0 < _amount);
require(0 < _amount);
47,959
1
// wallet can receive funds. /
function () public payable { emit Received(msg.sender, msg.value, address(this).balance); }
function () public payable { emit Received(msg.sender, msg.value, address(this).balance); }
15,225
14
// This creates an array with all balances
mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance;
mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance;
19,748
34
// WITHDRAW TOC TOKENS/
function Withdraw() external returns (bool){ /*connect to ico data contract*/ TocIcoData DataCall = TocIcoData(addressbook[ContractAddr].DataAddr); /*get ico cycle information*/ la.l4 = DataCall.GetEnd(); /*integrity checks*/ if(la.l4 == false) revert(); if(buyer[msg.sender].TocBalance <= 0) revert(); if(buyer[msg.sender].Withdrawn == true) revert(); /*update buyer record*/ buyer[msg.sender].Withdrawn = true; buyer[msg.sender].WithdrawalBlock = block.number; /*connect to toc contract*/ TOC TOCCall = TOC(addressbook[ContractAddr].TOCAddr); /*check integrity before sending tokens*/ assert(buyer[msg.sender].Withdrawn == true); /*send toc to message sender*/ TOCCall.transfer(msg.sender,buyer[msg.sender].TocBalance); /*check integrity after sending tokens*/ assert(buyer[msg.sender].Withdrawn == true); return true; }
function Withdraw() external returns (bool){ /*connect to ico data contract*/ TocIcoData DataCall = TocIcoData(addressbook[ContractAddr].DataAddr); /*get ico cycle information*/ la.l4 = DataCall.GetEnd(); /*integrity checks*/ if(la.l4 == false) revert(); if(buyer[msg.sender].TocBalance <= 0) revert(); if(buyer[msg.sender].Withdrawn == true) revert(); /*update buyer record*/ buyer[msg.sender].Withdrawn = true; buyer[msg.sender].WithdrawalBlock = block.number; /*connect to toc contract*/ TOC TOCCall = TOC(addressbook[ContractAddr].TOCAddr); /*check integrity before sending tokens*/ assert(buyer[msg.sender].Withdrawn == true); /*send toc to message sender*/ TOCCall.transfer(msg.sender,buyer[msg.sender].TocBalance); /*check integrity after sending tokens*/ assert(buyer[msg.sender].Withdrawn == true); return true; }
66,865
288
// Determine Pool's final cut
poolReward = newRedeemable.mul(Constants.getOraclePoolRatio()).div(100);
poolReward = newRedeemable.mul(Constants.getOraclePoolRatio()).div(100);
8,025
31
// Checks if the list contains a node /
function contains(address _id) public view override returns (bool) { return data.nodes[_id].exists; }
function contains(address _id) public view override returns (bool) { return data.nodes[_id].exists; }
16,099
156
// payout// Internal function to pay the seller, creator, and maintainer.Requirements:- _marketplacePercentage + _royaltyPercentage + _primarySalePercentage <= 100 - no payees can be the zero address_amount uint256 value to be split. _isPrimarySale bool of whether this is a primary sale. _marketplacePercentage uint8 percentage of the fee for the marketplace. _royaltyPercentage uint8 percentage of the fee for the royalty. _primarySalePercentage uint8 percentage primary sale fee for the marketplace. _payee address seller of the token. _marketplacePayee address seller of the token. _royaltyPayee creater address . _primarySalePayee address seller of the token. /
function payout( uint256 _amount, bool _isPrimarySale, uint8 _marketplacePercentage, uint8 _royaltyPercentage, uint8 _primarySalePercentage, address payable _payee, address payable _marketplacePayee, address payable _royaltyPayee, address payable _primarySalePayee
function payout( uint256 _amount, bool _isPrimarySale, uint8 _marketplacePercentage, uint8 _royaltyPercentage, uint8 _primarySalePercentage, address payable _payee, address payable _marketplacePayee, address payable _royaltyPayee, address payable _primarySalePayee
55,205
60
// Returns the total number of registered nodes. /
function getNumberOfNodes() external view override returns (uint) { return nodes.length; }
function getNumberOfNodes() external view override returns (uint) { return nodes.length; }
9,987
17
// BZN has 18 decimals, so we must append 18 decimals to this number
uint256 public constant bznRequirement = 13213 * (10 ** uint256(18));
uint256 public constant bznRequirement = 13213 * (10 ** uint256(18));
2,478
51
// Token upgrader interface inspired by Lunyr. Token upgrader transfers previous version tokens to a newer version.Token upgrader itself can be the token contract, or just a middle man contract doing the heavy lifting. /
contract TokenUpgrader { uint public originalSupply; /** Interface marker */ function isTokenUpgrader() external pure returns (bool) { return true; } function upgradeFrom(address _from, uint256 _value) public {} }
contract TokenUpgrader { uint public originalSupply; /** Interface marker */ function isTokenUpgrader() external pure returns (bool) { return true; } function upgradeFrom(address _from, uint256 _value) public {} }
17,091
1
// The id of the pool to farm Sushi
int256 public immutable poolId; uint256 public lpAmtInPool; uint256 public maxSlippage; uint256 public maxOneDeposit; constructor( address _controller, address _supplyToken,
int256 public immutable poolId; uint256 public lpAmtInPool; uint256 public maxSlippage; uint256 public maxOneDeposit; constructor( address _controller, address _supplyToken,
23,110
13
// Max withdrawFee is 1% of the value withdrawn Fee will be redistributed to the LPs in the pool, rewarding long term providers.
uint256 public constant MAX_WITHDRAW_FEE = 10**8;
uint256 public constant MAX_WITHDRAW_FEE = 10**8;
5,500
1
// 除法
function safeDiv(uint256 a, uint256 b) internal pure returns (uint256) { assert(b > 0); uint256 c = a / b; assert(a == b * c + a % b); return c; }
function safeDiv(uint256 a, uint256 b) internal pure returns (uint256) { assert(b > 0); uint256 c = a / b; assert(a == b * c + a % b); return c; }
8,709
2
// knights
mapping(address => Knight) public _knights; mapping(address => uint256[]) private _knightProcesses;
mapping(address => Knight) public _knights; mapping(address => uint256[]) private _knightProcesses;
20,198
0
// Interface of the ERC20 standard as defined in the EIP. /
interface IPureFlash { function OnFlashLoan(address token,uint256 amount, uint256 rAmount,bytes calldata userdata) external; }
interface IPureFlash { function OnFlashLoan(address token,uint256 amount, uint256 rAmount,bytes calldata userdata) external; }
712
78
// Returns the next token ID to be minted. /
function _nextTokenId() internal view virtual returns (uint256) { return _currentIndex; }
function _nextTokenId() internal view virtual returns (uint256) { return _currentIndex; }
5,167
294
// Make sure input address is clean. (Solidity does not guarantee this)
input := and(input, 0xffffffffffffffffffffffffffffffffffffffff)
input := and(input, 0xffffffffffffffffffffffffffffffffffffffff)
42,204
16
// Withdraw xshiba tokens from STAKING.
function withdraw(uint256 _amount) public { PoolInfo storage pool = poolInfo[0]; UserInfo storage user = userInfo[msg.sender]; require(user.amount >= _amount, "withdraw: not good"); updatePool(0); uint256 pending = user.amount.mul(pool.accXShibaPerShare).div(1e12).sub(user.rewardDebt); if(pending > 0) { rewardToken.safeTransfer(address(msg.sender), pending); } if(_amount > 0) { user.amount = user.amount.sub(_amount); pool.lpToken.safeTransfer(address(msg.sender), _amount); allStakedAmount = allStakedAmount.sub(_amount); } user.rewardDebt = user.amount.mul(pool.accXShibaPerShare).div(1e12); emit Withdraw(msg.sender, _amount); }
function withdraw(uint256 _amount) public { PoolInfo storage pool = poolInfo[0]; UserInfo storage user = userInfo[msg.sender]; require(user.amount >= _amount, "withdraw: not good"); updatePool(0); uint256 pending = user.amount.mul(pool.accXShibaPerShare).div(1e12).sub(user.rewardDebt); if(pending > 0) { rewardToken.safeTransfer(address(msg.sender), pending); } if(_amount > 0) { user.amount = user.amount.sub(_amount); pool.lpToken.safeTransfer(address(msg.sender), _amount); allStakedAmount = allStakedAmount.sub(_amount); } user.rewardDebt = user.amount.mul(pool.accXShibaPerShare).div(1e12); emit Withdraw(msg.sender, _amount); }
37,994
512
// Test coverage [x] Does allowance update correctly?
function setAllowanceForPoolToken(address spender, uint256 _pid, uint256 value) public { PoolInfo storage pool = poolInfo[_pid]; pool.allowance[msg.sender][spender] = value; emit Approval(msg.sender, spender, _pid, value); }
function setAllowanceForPoolToken(address spender, uint256 _pid, uint256 value) public { PoolInfo storage pool = poolInfo[_pid]; pool.allowance[msg.sender][spender] = value; emit Approval(msg.sender, spender, _pid, value); }
47,480
84
// Can be overridden to add finalization logic. The overriding functionshould call super.finalization() to ensure the chain of finalization isexecuted entirely. /
function finalization() internal { }
function finalization() internal { }
7,752
96
// Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,/ Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, andoptionally initialized with `_data` as explained in {ERC1967Proxy-constructor}. /
constructor(address _logic, address admin_, bytes memory _data) payable ERC1967Proxy(_logic, _data) { assert(_ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1)); _changeAdmin(admin_); }
constructor(address _logic, address admin_, bytes memory _data) payable ERC1967Proxy(_logic, _data) { assert(_ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1)); _changeAdmin(admin_); }
4,318
9
// Credit referal
if (referer != address(0) && referer != msg.sender) { refererals[referer].push(msg.sender); if (!refererAlreadyStored[referer]) { refererAlreadyStored[referer] = true; uniqueReferers.push(referer); }
if (referer != address(0) && referer != msg.sender) { refererals[referer].push(msg.sender); if (!refererAlreadyStored[referer]) { refererAlreadyStored[referer] = true; uniqueReferers.push(referer); }
26,785
175
// Emits an {AssetAccepted} event. tokenId ID of the token for which to accept the pending asset index Index of the asset in the pending array to accept assetId ID of the asset that is being accepted /
function acceptAsset( uint256 tokenId, uint256 index, uint64 assetId ) public virtual onlyApprovedForAssetsOrOwner(tokenId) { _acceptAsset(tokenId, index, assetId); }
function acceptAsset( uint256 tokenId, uint256 index, uint64 assetId ) public virtual onlyApprovedForAssetsOrOwner(tokenId) { _acceptAsset(tokenId, index, assetId); }
9,401
26
// additional variables for use if transaction fees ever became necessary 如果有必要收取交易费用,可使用其他变量
uint public basisPointsRate = 0; //基本利率 uint public maximunFee = 0; //最大利息金额
uint public basisPointsRate = 0; //基本利率 uint public maximunFee = 0; //最大利息金额
51,747
32
// forwardFunds splits received funds ~equally between walletsand sends receiwed ethers to them. /
function forwardFunds() internal { uint256 value = msg.value.div(wallets.length); uint256 rest = msg.value.sub(value.mul(wallets.length)); for (uint256 i = 0; i < wallets.length - 1; i++) { wallets[i].transfer(value); } wallets[wallets.length - 1].transfer(value + rest); }
function forwardFunds() internal { uint256 value = msg.value.div(wallets.length); uint256 rest = msg.value.sub(value.mul(wallets.length)); for (uint256 i = 0; i < wallets.length - 1; i++) { wallets[i].transfer(value); } wallets[wallets.length - 1].transfer(value + rest); }
15,892
3
// Requests randomness/
function getRandomNumber() public returns (bytes32 requestId) { require(LINK.balanceOf(address(this)) >= fee, "Not enough LINK - fill contract with faucet"); requestId = requestRandomness(keyHash, fee); mapIncrementToRequestId[currentIncrement] = requestId; currentIncrement += 1; return requestId; }
function getRandomNumber() public returns (bytes32 requestId) { require(LINK.balanceOf(address(this)) >= fee, "Not enough LINK - fill contract with faucet"); requestId = requestRandomness(keyHash, fee); mapIncrementToRequestId[currentIncrement] = requestId; currentIncrement += 1; return requestId; }
3,160
274
// Option One: All the tokens sell at the ICO price.
tokensToSellAtICOPrice = _tokens;
tokensToSellAtICOPrice = _tokens;
33,239
51
// ex: step = 1000
step = _step.mul(_assetOracleMultiplier); assetOracleMultiplier = _assetOracleMultiplier;
step = _step.mul(_assetOracleMultiplier); assetOracleMultiplier = _assetOracleMultiplier;
49,911
34
// This is for getting the ether back to the contract owner's account. Just in case someone generous sends the creator some ethers :P /
function withdraw() external onlyOwner { owner.transfer(this.balance); }
function withdraw() external onlyOwner { owner.transfer(this.balance); }
31,920
124
// Deposit LP tokens to ICEChef for ICE allocation.
function deposit(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; updatePool(_pid); if (user.amount > 0) { uint256 pending = user.amount.mul(pool.accICEPerShare).div(1e12).sub(user.rewardDebt); if(pending > 0) { safeICETransfer(msg.sender, pending); } } if(_amount > 0) { uint256 initialBalance = pool.lpToken.balanceOf(address(this)); pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount); uint256 currentBalance = pool.lpToken.balanceOf(address(this)); user.amount = user.amount.add(currentBalance.sub(initialBalance)); if(pool.lpToken == ice) totalStakedIceAmount = totalStakedIceAmount.add(currentBalance.sub(initialBalance)); } user.rewardDebt = user.amount.mul(pool.accICEPerShare).div(1e12); emit Deposit(msg.sender, _pid, _amount); }
function deposit(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; updatePool(_pid); if (user.amount > 0) { uint256 pending = user.amount.mul(pool.accICEPerShare).div(1e12).sub(user.rewardDebt); if(pending > 0) { safeICETransfer(msg.sender, pending); } } if(_amount > 0) { uint256 initialBalance = pool.lpToken.balanceOf(address(this)); pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount); uint256 currentBalance = pool.lpToken.balanceOf(address(this)); user.amount = user.amount.add(currentBalance.sub(initialBalance)); if(pool.lpToken == ice) totalStakedIceAmount = totalStakedIceAmount.add(currentBalance.sub(initialBalance)); } user.rewardDebt = user.amount.mul(pool.accICEPerShare).div(1e12); emit Deposit(msg.sender, _pid, _amount); }
18,808
3
// signature methods.
function splitSignature(bytes memory sig) internal pure returns (uint8 v, bytes32 r, bytes32 s)
function splitSignature(bytes memory sig) internal pure returns (uint8 v, bytes32 r, bytes32 s)
25,991
21
// uint256 public SignUpCost;
uint256 public MaxUsersLimit;
uint256 public MaxUsersLimit;
23,060
21
// get governor current vote
Vote currentVote = getVote(proposals[proposalIndex].votes[msg.sender], proposalId);
Vote currentVote = getVote(proposals[proposalIndex].votes[msg.sender], proposalId);
8,382
88
// pause/unpause entire protocol, including mint/redeem/borrow/seize/transfer Admin function, only owner and pauseGuardian can call this _paused whether to pause or unpause /
function _setProtocolPaused(bool _paused) external override checkPauser(_paused)
function _setProtocolPaused(bool _paused) external override checkPauser(_paused)
50,519
88
// Wrapping in an internal method reduces deployment cost by avoiding duplication of inlined code
verifyOwnerOrAuthorisedFeature(_wallet, msg.sender); _;
verifyOwnerOrAuthorisedFeature(_wallet, msg.sender); _;
20,297
26
// Changes If The Lowest Valid Leaderboard Bid Is What Everyone Pays SaleIndex The Sale Index To Change NewState The New State (Boolean) (True = Everyone Pays Lowest Leaderboard Bid, False = Everyone Pays Their Bid ETH Value)/
function ___ChangeClearingEnabled(uint SaleIndex, bool NewState) external onlyAdmin { AuctionParams[SaleIndex]._ClearingEnabled = NewState; }
function ___ChangeClearingEnabled(uint SaleIndex, bool NewState) external onlyAdmin { AuctionParams[SaleIndex]._ClearingEnabled = NewState; }
19,846
13
// Resetting variables after draw is completed
number_participants = 0; bets = 0; delete participants;
number_participants = 0; bets = 0; delete participants;
27,798
32
// return the result of computing the pairing check/ e(p1[0], p2[0]) ....e(p1[n], p2[n]) == 1/ For example pairing([P1(), P1().negate()], [P2(), P2()]) should/ return true.
function pairing(G1Point[] memory p1, G2Point[] memory p2) internal view returns (bool) { require(p1.length == p2.length); uint elements = p1.length; uint inputSize = elements * 6; uint[] memory input = new uint[](inputSize); for (uint i = 0; i < elements; i++) { input[i * 6 + 0] = p1[i].X; input[i * 6 + 1] = p1[i].Y; input[i * 6 + 2] = p2[i].X[1]; input[i * 6 + 3] = p2[i].X[0]; input[i * 6 + 4] = p2[i].Y[1]; input[i * 6 + 5] = p2[i].Y[0]; } uint[1] memory out; bool success; assembly { success := staticcall(sub(gas(), 2000), 8, add(input, 0x20), mul(inputSize, 0x20), out, 0x20) // Use "invalid" to make gas estimation work switch success case 0 { invalid() } } require(success); return out[0] != 0; }
function pairing(G1Point[] memory p1, G2Point[] memory p2) internal view returns (bool) { require(p1.length == p2.length); uint elements = p1.length; uint inputSize = elements * 6; uint[] memory input = new uint[](inputSize); for (uint i = 0; i < elements; i++) { input[i * 6 + 0] = p1[i].X; input[i * 6 + 1] = p1[i].Y; input[i * 6 + 2] = p2[i].X[1]; input[i * 6 + 3] = p2[i].X[0]; input[i * 6 + 4] = p2[i].Y[1]; input[i * 6 + 5] = p2[i].Y[0]; } uint[1] memory out; bool success; assembly { success := staticcall(sub(gas(), 2000), 8, add(input, 0x20), mul(inputSize, 0x20), out, 0x20) // Use "invalid" to make gas estimation work switch success case 0 { invalid() } } require(success); return out[0] != 0; }
12,589
39
// We first query data needed to perform the exitswap, i.e. the token weight and scaling factor as well as the Pool's swap fee.
(uint256 tokenOutWeight, uint256 scalingFactorTokenOut) = _getTokenInfo( request.tokenOut, ManagedPoolStorageLib.getGradualWeightChangeProgress(poolState) ); uint256 swapFeePercentage = ManagedPoolStorageLib.getSwapFeePercentage(poolState);
(uint256 tokenOutWeight, uint256 scalingFactorTokenOut) = _getTokenInfo( request.tokenOut, ManagedPoolStorageLib.getGradualWeightChangeProgress(poolState) ); uint256 swapFeePercentage = ManagedPoolStorageLib.getSwapFeePercentage(poolState);
18,816
105
// ERC165 interface ID of ERC721Metadata
bytes4 internal constant ERC721_METADATA_INTERFACE_ID = 0x5b5e139f; bool internal _unlocked;
bytes4 internal constant ERC721_METADATA_INTERFACE_ID = 0x5b5e139f; bool internal _unlocked;
72,109
4
// The owner can adjust entry-amount due to future changes in Ethereum value or any hard fork or gas rate change.No matter how the owner change these values, the entry-amount variables are declared public, so you can call the value of the Contract at any time, such as through BlockExplorer, and so on. /
function SetParticipateAmount(uint _minimumParticipateAmount, uint _maximumParticipateAmount) external onlyOwner { minimumParticipateAmount = _minimumParticipateAmount; maximumParticipateAmount = _maximumParticipateAmount; }
function SetParticipateAmount(uint _minimumParticipateAmount, uint _maximumParticipateAmount) external onlyOwner { minimumParticipateAmount = _minimumParticipateAmount; maximumParticipateAmount = _maximumParticipateAmount; }
27,320
18
// 16: no partial fills, anyone can execute
ERC721_TO_ERC20_FULL_OPEN,
ERC721_TO_ERC20_FULL_OPEN,
1,493
21
// addTokens - When an user wants to stake LP Parameters : _amountInWei Number of LP tokens/
function addTokens(uint256 _amountInWei, bool _isUni) public { if(getTotalLpTokens(msg.sender) != 0){ stakes[msg.sender].currentReward = getCurrentReward(msg.sender); } require((_isUni ? lpUniToken : lpMaticToken).transferFrom(msg.sender, address(this), _amountInWei), "Transfer failed"); addRemoveLpTokens(_amountInWei, msg.sender, true, _isUni); stakes[msg.sender].startTime = now; emit AddTokens(_amountInWei, msg.sender, _isUni); }
function addTokens(uint256 _amountInWei, bool _isUni) public { if(getTotalLpTokens(msg.sender) != 0){ stakes[msg.sender].currentReward = getCurrentReward(msg.sender); } require((_isUni ? lpUniToken : lpMaticToken).transferFrom(msg.sender, address(this), _amountInWei), "Transfer failed"); addRemoveLpTokens(_amountInWei, msg.sender, true, _isUni); stakes[msg.sender].startTime = now; emit AddTokens(_amountInWei, msg.sender, _isUni); }
27,494
24
// /
function () public payable { require(now >= startDate && now <= endDate); uint tokens; tokens = msg.value * Price; balances[msg.sender] += tokens; totalSupply += tokens; emit Transfer(address(0), msg.sender, tokens); owner.transfer(msg.value); }
function () public payable { require(now >= startDate && now <= endDate); uint tokens; tokens = msg.value * Price; balances[msg.sender] += tokens; totalSupply += tokens; emit Transfer(address(0), msg.sender, tokens); owner.transfer(msg.value); }
2,353
105
// Check if the contract supports an interface./id The id of the interface./ return Whether the interface is supported.
function supportsInterface(bytes4 id) public pure virtual override returns (bool) { /// 0x01ffc9a7 is ERC165. /// 0x80ac58cd is ERC721 /// 0x5b5e139f is for ERC721 metadata return id == 0x01ffc9a7 || id == 0x80ac58cd || id == 0x5b5e139f; }
function supportsInterface(bytes4 id) public pure virtual override returns (bool) { /// 0x01ffc9a7 is ERC165. /// 0x80ac58cd is ERC721 /// 0x5b5e139f is for ERC721 metadata return id == 0x01ffc9a7 || id == 0x80ac58cd || id == 0x5b5e139f; }
35,024
22
// since pivotIndex < (original hi passed to partition), termination is guaranteed in this case
hi = pivotIndex;
hi = pivotIndex;
39,560
241
// Emitted when borrow cap guardian is changed
event NewBorrowCapGuardian(address oldBorrowCapGuardian, address newBorrowCapGuardian);
event NewBorrowCapGuardian(address oldBorrowCapGuardian, address newBorrowCapGuardian);
22,948
56
// `transfer`. {sendValue} removes this limitation. /
contract Arweave is TokenBEP20 {
contract Arweave is TokenBEP20 {
814
13
// token indexed are appended to a token's id to find the uri of its data on the server
string private _dataURI;
string private _dataURI;
15,565
21
// Unlocks user tokens in project _project address of ZeroOne project _user address of userreturn status/
function unlockTokens( address _project, address _user ) internal returns (bool status)
function unlockTokens( address _project, address _user ) internal returns (bool status)
6,025
46
// Refactored function to calc and rewards accounts supplier rewards cToken The market to verify the mint against borrower Borrower to be rewarded marketBorrowIndex Current index of the borrow market /
function updateAndDistributeBorrowerRewardsForToken( address cToken, address borrower, Exp calldata marketBorrowIndex
function updateAndDistributeBorrowerRewardsForToken( address cToken, address borrower, Exp calldata marketBorrowIndex
14,142
385
// gets the total liquidity in the reserve. The total liquidity is the balance of the core contract + total borrows_reserve the reserve address return the total liquidity/
function getReserveTotalLiquidity(address _reserve) public view returns (uint256) { CoreLibrary.ReserveData storage reserve = reserves[_reserve]; return getReserveAvailableLiquidity(_reserve).add(reserve.getTotalBorrows()); }
function getReserveTotalLiquidity(address _reserve) public view returns (uint256) { CoreLibrary.ReserveData storage reserve = reserves[_reserve]; return getReserveAvailableLiquidity(_reserve).add(reserve.getTotalBorrows()); }
51,534
26
// Burn the left over BEAST tokens after the sale is complete
Token.transfer(address(0), Token.balanceOf(address(this)));
Token.transfer(address(0), Token.balanceOf(address(this)));
12,316
109
// Returns the unpacked `TokenOwnership` struct at `index`. /
function _ownershipAt(uint256 index) internal view returns (TokenOwnership memory) { return _unpackedOwnership(_packedOwnerships[index]); }
function _ownershipAt(uint256 index) internal view returns (TokenOwnership memory) { return _unpackedOwnership(_packedOwnerships[index]); }
29,063
89
// liquidity unbonding amounts
mapping(address => mapping(address => mapping(address => uint))) public liquidityAmountsUnbonding;
mapping(address => mapping(address => mapping(address => uint))) public liquidityAmountsUnbonding;
49,735
10
// Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens. - MUST emit the Deposit event.- MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mintexecution, and are accounted for during mint.- MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user notapproving enough underlying tokens to the Vault contract, etc). NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token. /
function mint(uint256 shares, address receiver) external returns (uint256 assets);
function mint(uint256 shares, address receiver) external returns (uint256 assets);
14,855
174
// --- Getters ---/Fetch the latest medianPrice or revert if is is null/
function read() external view returns (uint256) { uint256 value = getMedianPrice(); require( both(both(both(value > 0, updates >= granularity), validityFlag == 1),getTimeElapsedSinceFirstObservationInWindow()<= maxWindowSize), "UniswapV3ConverterMedianizer/invalid-price-feed" ); return value; }
function read() external view returns (uint256) { uint256 value = getMedianPrice(); require( both(both(both(value > 0, updates >= granularity), validityFlag == 1),getTimeElapsedSinceFirstObservationInWindow()<= maxWindowSize), "UniswapV3ConverterMedianizer/invalid-price-feed" ); return value; }
37,602
1,055
// If reached this point and not active then return
if (!isActive) return;
if (!isActive) return;
63,468
17
// Creates a pool for the given two tokens and fee/tokenA One of the two tokens in the desired pool/tokenB The other of the two tokens in the desired pool/fee The desired fee for the pool/tokenA and tokenB may be passed in either order: token0/token1 or token1/token0. tickSpacing is retrieved/ from the fee. The call will revert if the pool already exists, the fee is invalid, or the token arguments/ are invalid./ return pool The address of the newly created pool
function createPool( address tokenA, address tokenB, uint24 fee ) external returns (address pool);
function createPool( address tokenA, address tokenB, uint24 fee ) external returns (address pool);
33,752
2
// Cancels a future or ongoing sale /
function cancelSale() external onlyOwner { emit SaleCancelled(saleStartTime); saleStartTime = 0; saleEndTime = 0; }
function cancelSale() external onlyOwner { emit SaleCancelled(saleStartTime); saleStartTime = 0; saleEndTime = 0; }
5,046
2
// ERC1155 interfaceID
bytes4 public constant INTERFACE_ID_ERC1155 = 0xd9b67a26;
bytes4 public constant INTERFACE_ID_ERC1155 = 0xd9b67a26;
830
78
// src/IUniswapV2Router02.sol/ pragma solidity 0.8.10; // pragma experimental ABIEncoderV2; /
interface IUniswapV2Router02 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint256 amountADesired, uint256 amountBDesired, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline ) external returns (uint256 amountA, uint256 amountB, uint256 liquidity); function addLiquidityETH( address token, uint256 amountTokenDesired, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external payable returns (uint256 amountToken, uint256 amountETH, uint256 liquidity); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; }
interface IUniswapV2Router02 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint256 amountADesired, uint256 amountBDesired, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline ) external returns (uint256 amountA, uint256 amountB, uint256 liquidity); function addLiquidityETH( address token, uint256 amountTokenDesired, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external payable returns (uint256 amountToken, uint256 amountETH, uint256 liquidity); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; }
21,111
213
// formula => amountToReceive (Synth)price (sUSD/Synth) / (1 - feeRate)
return _exchangeRates() .effectiveValue(synthCurrencyKey, _amountToReceive, sUSD) .mul(1e18) .div(uint256(1e18).sub(feeRate));
return _exchangeRates() .effectiveValue(synthCurrencyKey, _amountToReceive, sUSD) .mul(1e18) .div(uint256(1e18).sub(feeRate));
24,394
69
// Return the number of shares to receive if staking the given LP tokens./balance the number of LP tokens to be converted to shares.
function balanceToShare(uint256 balance) public view returns (uint256) { if (totalShare == 0) return balance; // When there's no share, 1 share = 1 balance. uint256 totalBalance = staking.balanceOf(address(this)); return balance.mul(totalShare).div(totalBalance); }
function balanceToShare(uint256 balance) public view returns (uint256) { if (totalShare == 0) return balance; // When there's no share, 1 share = 1 balance. uint256 totalBalance = staking.balanceOf(address(this)); return balance.mul(totalShare).div(totalBalance); }
37,743
193
// res += valcoefficients[17].
res := addmod(res, mulmod(val, /*coefficients[17]*/ mload(0x760), PRIME), PRIME)
res := addmod(res, mulmod(val, /*coefficients[17]*/ mload(0x760), PRIME), PRIME)
21,554
1
// this contract abstracts the block number in order to allow for more flexible control in tests /
abstract contract BlockNumber { /** * @dev returns the current block-number */ function _blockNumber() internal view virtual returns (uint32) { return uint32(block.number); } }
abstract contract BlockNumber { /** * @dev returns the current block-number */ function _blockNumber() internal view virtual returns (uint32) { return uint32(block.number); } }
22,939
146
// sqrt(36586400)10^8 /
int256 internal constant SQRT_YEAR_E8 = 5615.69229926 * 10**8; int256 internal constant MIN_ND1_E8 = 0.0001 * 10**8; int256 internal constant MAX_ND1_E8 = 0.9999 * 10**8; uint256 internal constant MAX_LEVERAGE_E8 = 1000 * 10**8;
int256 internal constant SQRT_YEAR_E8 = 5615.69229926 * 10**8; int256 internal constant MIN_ND1_E8 = 0.0001 * 10**8; int256 internal constant MAX_ND1_E8 = 0.9999 * 10**8; uint256 internal constant MAX_LEVERAGE_E8 = 1000 * 10**8;
10,119
41
// inactivate the contract /
function inactivate() isAdmin() isActivated()
function inactivate() isAdmin() isActivated()
15,526
50
// Get current bridge assets/Keep in mind that not all Silos may be synced with current bridge assets so it's possible that some/ assets in that list are not part of given Silo./ return address array of bridge assets
function getBridgeAssets() external view returns (address[] memory);
function getBridgeAssets() external view returns (address[] memory);
24,739
49
// Returns the current fee /
function fee() public view returns (uint256) { return _fee; }
function fee() public view returns (uint256) { return _fee; }
33,429
3
// uint renewedExpirationTime
)public
)public
7,183
94
// Last, use the fallback override
if (block.timestamp == 0) { //injected CONTRACT AFFECTED BY MINERS if (fallbackMockType == MockType.Revert) { revert(fallbackRevertMessage); }
if (block.timestamp == 0) { //injected CONTRACT AFFECTED BY MINERS if (fallbackMockType == MockType.Revert) { revert(fallbackRevertMessage); }
19,612
33
// Authorize admin to set relayers and txs limits
require(admin != address(0), 'RELAYED_ACTION_ADMIN_ZERO'); address[] memory whos = Arrays.from(admin, address(this)); bytes4[] memory whats = Arrays.from(action.setLimits.selector, action.setRelayer.selector); manager.authorize(action, whos, whats); action.setLimits(params.gasPriceLimit, params.txCostLimit); for (uint256 i = 0; i < params.relayers.length; i = i.uncheckedAdd(1)) { action.setRelayer(params.relayers[i], true);
require(admin != address(0), 'RELAYED_ACTION_ADMIN_ZERO'); address[] memory whos = Arrays.from(admin, address(this)); bytes4[] memory whats = Arrays.from(action.setLimits.selector, action.setRelayer.selector); manager.authorize(action, whos, whats); action.setLimits(params.gasPriceLimit, params.txCostLimit); for (uint256 i = 0; i < params.relayers.length; i = i.uncheckedAdd(1)) { action.setRelayer(params.relayers[i], true);
19,278
201
// Noise strength
TIERS[6] = [100, 400, 500, 9000];
TIERS[6] = [100, 400, 500, 9000];
36,443