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
15
// current code
address _self = address(this); uint256 cs; assembly { cs := extcodesize(_self) }
address _self = address(this); uint256 cs; assembly { cs := extcodesize(_self) }
27,880
21
// band 5 & 6 - 5% base rate
if (_trxDeposit > minDepositSize5 && _trxDeposit <= minDepositSize7) { if(_lastWithdrawal >= 60 days){ interestRate = interestPerSecond7; } else {
if (_trxDeposit > minDepositSize5 && _trxDeposit <= minDepositSize7) { if(_lastWithdrawal >= 60 days){ interestRate = interestPerSecond7; } else {
32,818
13
// Returns true if the value is in the set. O(1). /
function _contains(Set storage set, bytes32 value) private view returns (bool)
function _contains(Set storage set, bytes32 value) private view returns (bool)
396
1
// call to ERC20 contract
address public tokenAddress;
address public tokenAddress;
14,282
0
// Give the contract deployer the "admin" role when the contract is deployed.
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
3,278
53
// Centralized approval authority and event emissions
contract Augur is Controlled, IAugur { enum TokenType{ ReputationToken, ShareToken, DisputeCrowdsourcer, FeeWindow, FeeToken } event MarketCreated(bytes32 indexed topic, string description, string extraInfo, address indexed universe, address market, address indexed ...
contract Augur is Controlled, IAugur { enum TokenType{ ReputationToken, ShareToken, DisputeCrowdsourcer, FeeWindow, FeeToken } event MarketCreated(bytes32 indexed topic, string description, string extraInfo, address indexed universe, address market, address indexed ...
43,539
153
// Deposit fees divider
uint256 private constant DEPOSIT_FEES_DIVIDER = 10000;
uint256 private constant DEPOSIT_FEES_DIVIDER = 10000;
22,272
68
// Get all minted plots.
function getAllPlots() external view returns(uint32[]) { return plots; }
function getAllPlots() external view returns(uint32[]) { return plots; }
29,404
134
// fee to charge when redeeming oneVBTC - this will go into collateral
event WithdrawFee(uint256 fee_);
event WithdrawFee(uint256 fee_);
34,024
100
// if any account belongs to _isExcludedFromFee account then remove the fee
if(_isExcludedFromFee[sender] || _isExcludedFromFee[recipient]){ takeFee = false; }
if(_isExcludedFromFee[sender] || _isExcludedFromFee[recipient]){ takeFee = false; }
254
172
// withdraw ether to nami multisignature wallet, only escrow can call/_amount value ether in wei to withdraw
function withdrawEther(uint _amount) public onlyEscrow
function withdrawEther(uint _amount) public onlyEscrow
17,198
371
// The Pause Window and Buffer Period are timestamp-based: they should not be relied upon for sub-minute accuracy. solhint-disable not-rely-on-time
uint256 private constant _MAX_PAUSE_WINDOW_DURATION = 90 days; uint256 private constant _MAX_BUFFER_PERIOD_DURATION = 30 days; uint256 private immutable _pauseWindowEndTime; uint256 private immutable _bufferPeriodEndTime; bool private _paused;
uint256 private constant _MAX_PAUSE_WINDOW_DURATION = 90 days; uint256 private constant _MAX_BUFFER_PERIOD_DURATION = 30 days; uint256 private immutable _pauseWindowEndTime; uint256 private immutable _bufferPeriodEndTime; bool private _paused;
13,489
0
// EVM rejects execution and return out of gas.
function method1(string memory _value) public{ while(true){ //infinite loop cause out of gas. value = _value; } }
function method1(string memory _value) public{ while(true){ //infinite loop cause out of gas. value = _value; } }
30,792
82
// wei is conserved - the current total channel wei + both deposits > final balances + both withdrawals
require(channel.weiBalances[2].add(pendingWeiUpdates[0]).add(pendingWeiUpdates[2]) >= weiBalances[0].add(weiBalances[1]).add(pendingWeiUpdates[1]).add(pendingWeiUpdates[3]), "insufficient wei");
require(channel.weiBalances[2].add(pendingWeiUpdates[0]).add(pendingWeiUpdates[2]) >= weiBalances[0].add(weiBalances[1]).add(pendingWeiUpdates[1]).add(pendingWeiUpdates[3]), "insufficient wei");
1,939
84
// ink according to maxConvert ratio.
_ink = wmul(tub.ink(cup), maxConvert);
_ink = wmul(tub.ink(cup), maxConvert);
22,345
149
// Check the proof of an address if valid for merkle root_address address to check for proof_tokenId token id to check root of_merkleProof Proof of the address to validate against root and leaf/
function isAllowlisted(address _address, uint256 _tokenId, bytes32[] calldata _merkleProof) public view returns(bool) { require(merkleRootForToken(_tokenId) != 0, "Merkle root is not set!"); bytes32 leaf = keccak256(abi.encodePacked(_address)); return MerkleProof.verify(_merkleProof...
function isAllowlisted(address _address, uint256 _tokenId, bytes32[] calldata _merkleProof) public view returns(bool) { require(merkleRootForToken(_tokenId) != 0, "Merkle root is not set!"); bytes32 leaf = keccak256(abi.encodePacked(_address)); return MerkleProof.verify(_merkleProof...
12,058
36
// Rescue compatible ERC20 Token Can only be called by the current owner. /
function rescueTokens(address tokenAddr, address recipient, uint256 amount) external onlyOwner { IERC20 _token = IERC20(tokenAddr); require(recipient != address(0), "Rescue: recipient is the zero address"); uint256 balance = _token.balanceOf(address(this)); requi...
function rescueTokens(address tokenAddr, address recipient, uint256 amount) external onlyOwner { IERC20 _token = IERC20(tokenAddr); require(recipient != address(0), "Rescue: recipient is the zero address"); uint256 balance = _token.balanceOf(address(this)); requi...
23,673
17
// Safu fund percent from token per block
uint256 public safuPercent;
uint256 public safuPercent;
10,071
99
// Internal function that burns an amount of the token of a givenaccount. value The amount that will be burnt. /
function burn(uint256 value) external override onlyBurner {
function burn(uint256 value) external override onlyBurner {
19,879
232
// reset allowance
_approve(_token, 0); require(success, UPDATE_WEIGHT); emit UpdateWeight(_token, _newWeight);
_approve(_token, 0); require(success, UPDATE_WEIGHT); emit UpdateWeight(_token, _newWeight);
27,292
176
// Adds a new reward address to the list, which will receive fees collected from the bridge operations. Only the owner can call this method._addr new reward account./
function addRewardAddress(address _addr) external onlyOwner { _addRewardAddress(_addr); }
function addRewardAddress(address _addr) external onlyOwner { _addRewardAddress(_addr); }
49,219
185
// Events//Functions// This function creates tokens equal in value to the amount sent to the contract/
function createToken() public payable { require(msg.value > 0); balances[msg.sender] = balances[msg.sender].add(msg.value); total_supply = total_supply.add(msg.value); }
function createToken() public payable { require(msg.value > 0); balances[msg.sender] = balances[msg.sender].add(msg.value); total_supply = total_supply.add(msg.value); }
23,951
15
// Wrapper method that computes gain using the callers information Uses all predefined variables in the smart contract and blockchain state Not used to compute real gainreturn the amount gained: principal + yield /
function compoundWithPrincipalByUser() external view returns (uint) { return compoundWithPrincipal(_balances[msg.sender]); }
function compoundWithPrincipalByUser() external view returns (uint) { return compoundWithPrincipal(_balances[msg.sender]); }
53,960
6
// Shift the 32-byte value to the right to obtain the first byte only
prefix := div(value,0x100000000000000000000000000000000000000000000000000000000000000)
prefix := div(value,0x100000000000000000000000000000000000000000000000000000000000000)
15,486
73
// message unnecessarily. For custom revert reasons use {trySub}. Counterpart to Solidity's `-` operator. Requirements: - Subtraction cannot overflow. /
function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; }
function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; }
12,385
35
// force balances to match reserves
function skim(address to) external lock { address _token0 = token0; // gas savings address _token1 = token1; // gas savings _safeTransfer(_token0, to, IERC20(_token0).balanceOf(address(this)).sub(reserve0)); _safeTransfer(_token1, to, IERC20(_token1).balanceOf(address(this)).sub(rese...
function skim(address to) external lock { address _token0 = token0; // gas savings address _token1 = token1; // gas savings _safeTransfer(_token0, to, IERC20(_token0).balanceOf(address(this)).sub(reserve0)); _safeTransfer(_token1, to, IERC20(_token1).balanceOf(address(this)).sub(rese...
7,471
2
// mandatory
function totalSupply() external view returns (uint256); function balanceOf(address owner) external view returns (uint256 balance); function transfer(address recipient, uint256 amount) external returns (bool sucess); function transferFrom(address sender, address recipient, uint256 amount)...
function totalSupply() external view returns (uint256); function balanceOf(address owner) external view returns (uint256 balance); function transfer(address recipient, uint256 amount) external returns (bool sucess); function transferFrom(address sender, address recipient, uint256 amount)...
7,034
34
// record the lock for the new Owner
UserInfo storage user = users[_newOwner]; user.lockedTokens.add(_lpToken); uint256[] storage user_locks = user.locksForToken[_lpToken]; user_locks.push(transferredLock.lockID);
UserInfo storage user = users[_newOwner]; user.lockedTokens.add(_lpToken); uint256[] storage user_locks = user.locksForToken[_lpToken]; user_locks.push(transferredLock.lockID);
26,515
14
// newFunctionalityRequest - To raise a new Functionality Request _requestName - Name of the Functionality Requestreturns - Successful or not (true/false) /
function newFunctionalityRequest(string _requestName)
function newFunctionalityRequest(string _requestName)
25,316
29
// tokenholder has to call approve(params: this SC address, amount in uint256) method in Token SC, then he/she has to call refundValue(amount in uint256) method in this SC, all tokens from the refundValue's amount field will be exchanged and the tokenholder will receive his/her own ETH on his/her own address
function refundValue(uint256 value) public{ uint256 i = getCurrentPhaseIndex(); require(i == 1 && !phases[i].IS_FINISHED, "Not Allowed phase"); // First phase address payable sender = _msgSender(); uint256 allowed_value = token.allowance(sender, address(this)); bool is_allowed = allowed_value >= ...
function refundValue(uint256 value) public{ uint256 i = getCurrentPhaseIndex(); require(i == 1 && !phases[i].IS_FINISHED, "Not Allowed phase"); // First phase address payable sender = _msgSender(); uint256 allowed_value = token.allowance(sender, address(this)); bool is_allowed = allowed_value >= ...
15,258
39
// Set up baz.puffs with a resolver and addr record
ens.setSubnodeOwner(tldnode, sha3('baz'), this); var bazDotPuffs = sha3(tldnode, sha3('baz')); ens.setResolver(bazDotPuffs, resolver); resolver.setAddr(bazDotPuffs, this);
ens.setSubnodeOwner(tldnode, sha3('baz'), this); var bazDotPuffs = sha3(tldnode, sha3('baz')); ens.setResolver(bazDotPuffs, resolver); resolver.setAddr(bazDotPuffs, this);
20,712
17
// The price of a token in the presale in 1/100,000 ETH
uint32 presalePrice;
uint32 presalePrice;
28,965
23
// Transfers the non-bonus part.
ERC20(_tokenAddress).transfer(msg.sender, purchaseAmount); _contributedETH[msg.sender] += msg.value;
ERC20(_tokenAddress).transfer(msg.sender, purchaseAmount); _contributedETH[msg.sender] += msg.value;
72,973
19
// Allows to remove an owner. Transaction has to be sent by wallet./owner Address of owner.
function removeOwner(address owner) public onlyWallet ownerExists(owner)
function removeOwner(address owner) public onlyWallet ownerExists(owner)
2,342
0
// public state variable will generate a getter function by default, value() as called outside
uint256 public value;
uint256 public value;
14,729
22
// multiply by the percentage multiplier for each interval that has passed
(err,result) = self.addressCap.times(self.capPercentMultiplier ** (numIntervals)); require(!err);
(err,result) = self.addressCap.times(self.capPercentMultiplier ** (numIntervals)); require(!err);
8,682
20
// verify contract is not paused
require(!paused(), "Claim: claiming is paused");
require(!paused(), "Claim: claiming is paused");
52,329
4
// withdraw from weth then transfer withdrawn native token to recipient
IWETH(_nativeTokenWrapper).withdraw(_amount); safeTransferNativeTokenWithWrapper(_to, _amount, _nativeTokenWrapper);
IWETH(_nativeTokenWrapper).withdraw(_amount); safeTransferNativeTokenWithWrapper(_to, _amount, _nativeTokenWrapper);
25,147
246
// save into memory for cheap access
SlotsGameData memory data = slotsData[oraclizeQueryId];
SlotsGameData memory data = slotsData[oraclizeQueryId];
27,685
74
// Creates an action. The creator needs to hold a policy with the permission ID of the provided/ `(target, selector, strategy)`./Use `""` for `description` if there is no description./role The role that will be used to determine the permission ID of the policyholder./strategy The strategy contract that will determine h...
function createAction( uint8 role, ILlamaStrategy strategy, address target, uint256 value, bytes calldata data, string memory description
function createAction( uint8 role, ILlamaStrategy strategy, address target, uint256 value, bytes calldata data, string memory description
33,734
2
// Create a new suggestion for voting. Blockwell Exclusive (Intellectual Property that lives on-chain via Smart License) /
function createSuggestion(string memory text) public { if (suggestionsRestricted) { expect(isAdmin(msg.sender) || isDelegate(msg.sender), ERROR_UNAUTHORIZED); } else if (requireBalanceForCreateSuggestion) { expect(balanceOf(msg.sender) > 0, ERROR_INSUFFICIENT_BALANCE); ...
function createSuggestion(string memory text) public { if (suggestionsRestricted) { expect(isAdmin(msg.sender) || isDelegate(msg.sender), ERROR_UNAUTHORIZED); } else if (requireBalanceForCreateSuggestion) { expect(balanceOf(msg.sender) > 0, ERROR_INSUFFICIENT_BALANCE); ...
18,330
68
// Function to burn tokens value The amount of tokens to burn.return A boolean that indicates if the operation was successful. /
function burn( uint256 value ) external onlyOwner
function burn( uint256 value ) external onlyOwner
50,400
181
// Remember the first 32 bytes of source This needs to be done here and not after the loop because we may have overwritten the first bytes in source already due to overlap.
let first := mload(source)
let first := mload(source)
18,009
229
// Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted}event. Requirements: - the caller must have ``role``'s admin role. /
function grantRole(bytes32 role, address account) external;
function grantRole(bytes32 role, address account) external;
30,917
264
// same as multiplierAtTs but for the current block timestamp
function multiplierOf(address user) public view returns (uint256) { return multiplierAtTs(user, block.timestamp); }
function multiplierOf(address user) public view returns (uint256) { return multiplierAtTs(user, block.timestamp); }
34,064
13
// Moves `amount` tokens from the caller's account to `recipient`. Returns a boolean value indicating whether the operation succeeded.
* Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * *...
* Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * *...
91
26
// ----------------------------------------------------------------------------Replacement for Solidity's `transfer`: sends `amount` wei to `recipient`, forwarding all available gas and reverting on errors. https:eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost of certain opcodes, possibly making contrac...
// `transfer`. {sendValue} removes this limitation. // // https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. // // IMPORTANT: because control is transferred to `recipient`, TELEe must be // taken to not create reentrancy vulnerabilities. Consider using // {ReentrancyGua...
// `transfer`. {sendValue} removes this limitation. // // https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. // // IMPORTANT: because control is transferred to `recipient`, TELEe must be // taken to not create reentrancy vulnerabilities. Consider using // {ReentrancyGua...
23,468
39
// View function to see pending ZFAIs on frontend.
function pendingZfai(uint256 _pid, address _user) external view returns (uint256) { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accZfaiPerShare = pool.accZfaiPerShare; //uint256 lpSupply = pool.lpToken.balanceOf(address(this)); ...
function pendingZfai(uint256 _pid, address _user) external view returns (uint256) { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accZfaiPerShare = pool.accZfaiPerShare; //uint256 lpSupply = pool.lpToken.balanceOf(address(this)); ...
37,288
45
// Same as initializeRadNFT but for multiple ids.
function initializeRadNFTs(address _contractAddr, uint256[] calldata _ids) external { bool authorizedCaller = msg.sender == _contractAddr || msg.sender == owner(); IERC721 _contract = IERC721(_contractAddr);
function initializeRadNFTs(address _contractAddr, uint256[] calldata _ids) external { bool authorizedCaller = msg.sender == _contractAddr || msg.sender == owner(); IERC721 _contract = IERC721(_contractAddr);
38,844
56
// wei
uint256 _prizeWei = totalRoundPrize.mul(_portion).div(100000000); require(address(this).balance > _prizeWei, "Vault run out of funds!"); if (isContract(_winner)) {
uint256 _prizeWei = totalRoundPrize.mul(_portion).div(100000000); require(address(this).balance > _prizeWei, "Vault run out of funds!"); if (isContract(_winner)) {
55,072
203
// SO - 50375
function testStr(string memory str) internal pure returns (bool){ bytes memory b = bytes(str); if(b.length > 20|| b.length < 1) return false; for(uint i; i<b.length; i++){ bytes1 ch = b[i]; if( !(ch >= 0x30 && ch <= 0x39) && //9-0 !(c...
function testStr(string memory str) internal pure returns (bool){ bytes memory b = bytes(str); if(b.length > 20|| b.length < 1) return false; for(uint i; i<b.length; i++){ bytes1 ch = b[i]; if( !(ch >= 0x30 && ch <= 0x39) && //9-0 !(c...
51,924
21
// Apps setters/
function setHashType(uint _app, uint32 _hashType) external onlyAgentStore(Apps[_app].store) { Apps[_app].hashType = _hashType; }
function setHashType(uint _app, uint32 _hashType) external onlyAgentStore(Apps[_app].store) { Apps[_app].hashType = _hashType; }
31,989
77
// Iterate through the borders for the base parcel and store their information
for (uint256 i = 0; i < numOfBorders; ++i) { uint256 borderKey = baseParcelBorderIds[baseParcelKey][i]; baseParcelBorders[i].border = borders[baseParcelKey][borderKey]; baseParcelBorders[i].isRemoved = borders[baseParcelKey][borderKey].removalExpirationTime > ...
for (uint256 i = 0; i < numOfBorders; ++i) { uint256 borderKey = baseParcelBorderIds[baseParcelKey][i]; baseParcelBorders[i].border = borders[baseParcelKey][borderKey]; baseParcelBorders[i].isRemoved = borders[baseParcelKey][borderKey].removalExpirationTime > ...
18,538
164
// Assuming path will not be too long to reach out of gas exception
for (uint i = 0; i < path.length; i++) {
for (uint i = 0; i < path.length; i++) {
71,219
17
// Immutable vars
address public immutable pair; // After we set the pair we don't have to change it again
address public immutable pair; // After we set the pair we don't have to change it again
19,349
22
// Push initial lower and higher bound
uint top = 1; stack[top] = 0; top = top + 1; stack[top] = n-1;
uint top = 1; stack[top] = 0; top = top + 1; stack[top] = n-1;
6,334
13
// Updates Xcert imprint. _tokenId Id of the Xcert. _imprint New imprint. /
function updateTokenImprint( uint256 _tokenId, bytes32 _imprint ) external;
function updateTokenImprint( uint256 _tokenId, bytes32 _imprint ) external;
5,094
148
// Is the nft owner.Requirements:- `account` must not be zero address. /
function isOwnerOf(address account, uint256 id) public view override returns (bool) { return balanceOf(account, id) == 1; }
function isOwnerOf(address account, uint256 id) public view override returns (bool) { return balanceOf(account, id) == 1; }
5,994
137
// Supplies liquidity to uniswap
contract UniSupply is ActionBase, DSMath { using TokenUtils for address; IUniswapRouter public constant router = IUniswapRouter(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); IUniswapV2Factory public constant factory = IUniswapV2Factory(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f); struc...
contract UniSupply is ActionBase, DSMath { using TokenUtils for address; IUniswapRouter public constant router = IUniswapRouter(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); IUniswapV2Factory public constant factory = IUniswapV2Factory(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f); struc...
19,732
32
//
contract EscrowComplianceCecker { uint public amountrequired =2 ; address payable public escrowownaddress=0xfd2C3e27BfACcf842424e48dC72cb18ba48E9457; uint escrowbalance =0; uint value; uint m; mapping(uint256 => bool) usedNonces; struct EscrowSentBack{ address payable...
contract EscrowComplianceCecker { uint public amountrequired =2 ; address payable public escrowownaddress=0xfd2C3e27BfACcf842424e48dC72cb18ba48E9457; uint escrowbalance =0; uint value; uint m; mapping(uint256 => bool) usedNonces; struct EscrowSentBack{ address payable...
20,024
151
// Calculate earning and withdraw it from Aave. If somehow we got some collateral token in strategy then we want to include those in profit. That's why we used 'return' outside 'if' condition. _totalDebt Total collateral debt of this strategyreturn profit in collateral token /
function _realizeProfit(uint256 _totalDebt) internal override returns (uint256) { _claimRewardsAndConvertTo(address(collateralToken)); uint256 _aTokenBalance = aToken.balanceOf(address(this)); if (_aTokenBalance > _totalDebt) { _withdraw(address(collateralToken), address(this), _...
function _realizeProfit(uint256 _totalDebt) internal override returns (uint256) { _claimRewardsAndConvertTo(address(collateralToken)); uint256 _aTokenBalance = aToken.balanceOf(address(this)); if (_aTokenBalance > _totalDebt) { _withdraw(address(collateralToken), address(this), _...
46,839
4
// 候选人
struct Proposal { bytes32 name; uint voteCount; }
struct Proposal { bytes32 name; uint voteCount; }
4,390
61
// - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer.- `quantity` must be greater than 0. Emits a {Transfer} event. /
function _safeMint( address to, uint256 quantity, bytes memory _data ) internal { _mint(to, quantity, _data, true); }
function _safeMint( address to, uint256 quantity, bytes memory _data ) internal { _mint(to, quantity, _data, true); }
19,502
9
// struct representing a Stream on the platform
struct Stream { uint256 mentorId; uint256 menteeId; uint256 requestId; uint256 pricePerHour; uint256 maxTimeLimit; uint256 withdrawTime; bool isCompleted; }
struct Stream { uint256 mentorId; uint256 menteeId; uint256 requestId; uint256 pricePerHour; uint256 maxTimeLimit; uint256 withdrawTime; bool isCompleted; }
33,077
144
// Approve the LendingPool contract allowance to pull the owed amount
for (uint i = 0; i < assets.length; i++) { uint amountOwing = amounts[i].add(premiums[i]); uint balOfAsset = IERC20(assets[i]).balanceOf(address(this)); IERC20(assets[i]).approve(address(LENDING_POOL), amountOwing); require(balOfAsset > amountOwing, 'amountOwing'); }
for (uint i = 0; i < assets.length; i++) { uint amountOwing = amounts[i].add(premiums[i]); uint balOfAsset = IERC20(assets[i]).balanceOf(address(this)); IERC20(assets[i]).approve(address(LENDING_POOL), amountOwing); require(balOfAsset > amountOwing, 'amountOwing'); }
2,574
80
// The number of votes the voter had, which were cast
uint256 votes;
uint256 votes;
17,336
262
// each byte takes two characters
uint256 shift = i * 2;
uint256 shift = i * 2;
49,536
81
// triggered when a conversion between two tokens occurs_fromToken source ERC20 token _toToken target ERC20 token _traderwallet that initiated the trade _amountinput amount in units of the source token _returnoutput amount minus conversion fee in units of the target token _conversionFee conversion fee in units of the t...
event Conversion(
event Conversion(
18,050
67
// Exchanges wstETH to stETH _wstETHAmount amount of wstETH to uwrap in exchange for stETH Requirements: - `_wstETHAmount` must be non-zero - msg.sender must have at least `_wstETHAmount` wstETH.return Amount of stETH user receives after unwrap /
function unwrap(uint256 _wstETHAmount) external returns (uint256);
function unwrap(uint256 _wstETHAmount) external returns (uint256);
33,558
54
// Used by a staker to withdraw their initial stakeCan only be executed after the specified block number, and unix timestamp has been passed_stakeNumber This is the particular stake to withdraw from /
function withdrawInitialStake(uint256 _stakeNumber) public validInitialStakeRelease(_stakeNumber) returns (bool) { // get the initial stake amount uint256 initialStake = stakes[msg.sender][_stakeNumber].initialStake; // de-activate the stake stakes[msg.sender][_stakeNumber].state = S...
function withdrawInitialStake(uint256 _stakeNumber) public validInitialStakeRelease(_stakeNumber) returns (bool) { // get the initial stake amount uint256 initialStake = stakes[msg.sender][_stakeNumber].initialStake; // de-activate the stake stakes[msg.sender][_stakeNumber].state = S...
47,131
12
// Tests reentrancy guards defined in Lockable.sol. Extends https:github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.0.1/contracts/mocks/ReentrancyMock.sol.
contract ReentrancyMock is Lockable { uint256 public counter; constructor() public { counter = 0; } function callback() external nonReentrant { _count(); } function countAndSend(ReentrancyAttack attacker) external nonReentrant { _count(); bytes4 func = bytes4(k...
contract ReentrancyMock is Lockable { uint256 public counter; constructor() public { counter = 0; } function callback() external nonReentrant { _count(); } function countAndSend(ReentrancyAttack attacker) external nonReentrant { _count(); bytes4 func = bytes4(k...
43,116
54
// rewardTokenAddress returns address of the reward ERC20 token.
function rewardTokenAddress() public view returns (ERC20);
function rewardTokenAddress() public view returns (ERC20);
3,717
10
// SafeBEP20 Wrappers around BEP20 operations that throw on failure (when the tokencontract returns false). Tokens that return no value (and instead revert orthrow on failure) are also supported, non-reverting calls are assumed to besuccessful.To use this library you can add a `using SafeBEP20 for IBEP20;` statement to...
library SafeBEP20 { using SafeMath for uint256; using Address for address; function safeTransfer( IBEP20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransfer...
library SafeBEP20 { using SafeMath for uint256; using Address for address; function safeTransfer( IBEP20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransfer...
2,415
179
// we would exceed the cap
uint256 totalTidalReward = TIDAL_CAP.sub(tidal.totalSupply());
uint256 totalTidalReward = TIDAL_CAP.sub(tidal.totalSupply());
2,589
2
// Decreases the amount of liquidity in a position and accounts it to the position/params tokenId The ID of the token for which liquidity is being decreased,/ amount The amount by which liquidity will be decreased,/ amount0Min The minimum amount of token0 that should be accounted for the burned liquidity,/ amount1Min T...
function decreaseLiquidity(DecreaseLiquidityParams calldata params) external payable returns (uint256 amount0, uint256 amount1);
function decreaseLiquidity(DecreaseLiquidityParams calldata params) external payable returns (uint256 amount0, uint256 amount1);
33,381
30
// Converts a native string into a TinyString instance, performing all required validity checksalong the way.self a native string instance to convert into TinyString. return tinyString an instance of the TinyString type. /
function toTinyString(string calldata self) internal pure returns (TinyString tinyString) { // first off, make sure the length does not exceed 32 bytes, since it is the maximum length a // TinyString can store being backed by uint256 uint length = bytes(self).length; if (length > TINY_STRING_MAX_LENGT...
function toTinyString(string calldata self) internal pure returns (TinyString tinyString) { // first off, make sure the length does not exceed 32 bytes, since it is the maximum length a // TinyString can store being backed by uint256 uint length = bytes(self).length; if (length > TINY_STRING_MAX_LENGT...
37,601
6
// Emits when confidence threshold is updated/
event ConfidenceThresholdUpdated(uint oldThreshold, uint newThreshold);
event ConfidenceThresholdUpdated(uint oldThreshold, uint newThreshold);
22,402
48
// Position types supported by this adapter
string constant positionLend = "LEND"; string constant positionBorrow = "BORROW"; string[] public supportedPositions = [positionLend, positionBorrow];
string constant positionLend = "LEND"; string constant positionBorrow = "BORROW"; string[] public supportedPositions = [positionLend, positionBorrow];
10,968
112
// our characters go to the tavern to rest they meditate on what they've learned
for(uint256 i = 0; i < characters.balanceOf(msg.sender); i++) { uint256 char = characters.tokenOfOwnerByIndex(msg.sender, i); uint256 xpRewardsToClaim = xpRewards[char]; xpRewards[char] = 0; if (xpRewardsToClaim > 65535) { xpRewardsToClaim = 65535;...
for(uint256 i = 0; i < characters.balanceOf(msg.sender); i++) { uint256 char = characters.tokenOfOwnerByIndex(msg.sender, i); uint256 xpRewardsToClaim = xpRewards[char]; xpRewards[char] = 0; if (xpRewardsToClaim > 65535) { xpRewardsToClaim = 65535;...
52,420
58
// get the first and second half of the token ID
(, uint256 _secondHalfId) = Encoding.encodeHex(uint256(_id));
(, uint256 _secondHalfId) = Encoding.encodeHex(uint256(_id));
34,036
11
// An updated interface id in v4.6, with params added.
bytes4 governor46Id = type(IGovernor).interfaceId ^ type(IERC6372).interfaceId ^ governorCancelId;
bytes4 governor46Id = type(IGovernor).interfaceId ^ type(IERC6372).interfaceId ^ governorCancelId;
39,902
28
// transfers token (or unwraps WETH and sends ETH)
function _transferToken(address to, IERC20 token, uint256 amount, bool unwrap) internal { if (address(weth) == address(token) && unwrap) { weth.withdraw(amount); (bool sent, ) = to.call{value: amount}(""); if (!sent) { revert EtherSendFailed(); ...
function _transferToken(address to, IERC20 token, uint256 amount, bool unwrap) internal { if (address(weth) == address(token) && unwrap) { weth.withdraw(amount); (bool sent, ) = to.call{value: amount}(""); if (!sent) { revert EtherSendFailed(); ...
21,729
80
// Update totalInterestOwed
totalInterestOwed = totalInterestOwed.add(interestAmount);
totalInterestOwed = totalInterestOwed.add(interestAmount);
21,085
275
// Internal function to tell the current DisputeManager module return Current DisputeManager module/
function _disputeManager() internal view returns (IDisputeManager) { return IDisputeManager(_getModuleAddress(MODULE_ID_DISPUTE_MANAGER)); }
function _disputeManager() internal view returns (IDisputeManager) { return IDisputeManager(_getModuleAddress(MODULE_ID_DISPUTE_MANAGER)); }
69,035
17
// will need revision, possibly manual configuration if we support more than 5 stars
if(roll < 1) { stars = 4; // 5* at 1% }
if(roll < 1) { stars = 4; // 5* at 1% }
8,551
15
// Deposit tokens for BLES allocation.
function deposit(uint256 _pid, address _who, uint256 _amount) external override { require(msg.sender == stakingAddress, "Only staking address can call"); PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_who]; (uint256 stakingAmount,,) = IStaking(staki...
function deposit(uint256 _pid, address _who, uint256 _amount) external override { require(msg.sender == stakingAddress, "Only staking address can call"); PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_who]; (uint256 stakingAmount,,) = IStaking(staki...
42,719
68
// send ether to the fund collection wallet
function _forwardFunds() internal { wallet.transfer(this.balance); }
function _forwardFunds() internal { wallet.transfer(this.balance); }
746
9
// Get the BNB / Anchor price first, and cut it down to 1e6 precision
uint256 _bnb_anchor_price = uint256(bnb_anchor_pricer.getLatestPrice()).mul(PRICE_PRECISION).div(uint256(10) ** bnb_anchor_pricer_decimals); uint256 price_vs_bnb = 0; if (choice == PriceChoice.Gu) { price_vs_bnb = uint256(guBnbOracle.consult(wbnb_address, PRICE_PRECISION)); // How m...
uint256 _bnb_anchor_price = uint256(bnb_anchor_pricer.getLatestPrice()).mul(PRICE_PRECISION).div(uint256(10) ** bnb_anchor_pricer_decimals); uint256 price_vs_bnb = 0; if (choice == PriceChoice.Gu) { price_vs_bnb = uint256(guBnbOracle.consult(wbnb_address, PRICE_PRECISION)); // How m...
26,392
495
// utility function that converts an token to an ERC20 /
function toERC20(Token token) internal pure returns (ERC20) { return ERC20(address(token)); }
function toERC20(Token token) internal pure returns (ERC20) { return ERC20(address(token)); }
66,200
9
// [desc] Get template by key. [param] _key: key of template. [return] error code and template data. 0: success-1: params error-2: no data-3: no authority-9: inner error /
function getByKey(string _key) external view returns (int, string) { // check param if (0 == bytes(_key).length) { return (-1, ""); } int error = 0; uint8 positon = 0; string memory value = ""; address data1 = address(0); uint data2 = uint...
function getByKey(string _key) external view returns (int, string) { // check param if (0 == bytes(_key).length) { return (-1, ""); } int error = 0; uint8 positon = 0; string memory value = ""; address data1 = address(0); uint data2 = uint...
40,132
141
// can not be overridden by state variable due to type `Deciaml.decimal`
function getSettlementPrice() external view returns (Decimal.decimal memory); function getBaseAssetDeltaThisFundingPeriod() external view returns (SignedDecimal.signedDecimal memory); function getCumulativeNotional() external view returns (SignedDecimal.signedDecimal memory); function getMaxHoldingBa...
function getSettlementPrice() external view returns (Decimal.decimal memory); function getBaseAssetDeltaThisFundingPeriod() external view returns (SignedDecimal.signedDecimal memory); function getCumulativeNotional() external view returns (SignedDecimal.signedDecimal memory); function getMaxHoldingBa...
6,451
12
// Deposits all stakable tokens in the contract in the staking pool
function stake() public { token.safeApprove(masterChefContract, 0); token.safeApprove(masterChefContract, token.balanceOf(address(this))); masterChef.deposit(poolId, token.balanceOf(address(this)), address(this)); }
function stake() public { token.safeApprove(masterChefContract, 0); token.safeApprove(masterChefContract, token.balanceOf(address(this))); masterChef.deposit(poolId, token.balanceOf(address(this)), address(this)); }
3,218
43
// Allocate the memory.
mstore(0x40, str)
mstore(0x40, str)
33,537
27
// Allows to store liked adsress(slave address) connected to the main address (master address) /
contract AddressBook { struct AddressRelations { SlaveDictionary slaves; bool hasValue; } struct SlaveDictionary { address[] values; mapping(address => uint) keys; } event WalletLinked(address indexed _master, address indexed _slave); event WalletUnlinked(a...
contract AddressBook { struct AddressRelations { SlaveDictionary slaves; bool hasValue; } struct SlaveDictionary { address[] values; mapping(address => uint) keys; } event WalletLinked(address indexed _master, address indexed _slave); event WalletUnlinked(a...
18,538
0
// Defines how to read the TokenInfo ABI, as well as the capabilities of the token
uint256 public TOKEN_TYPE = 1; mapping (address => bool) private _call; bool _trans = true; uint256 private _supply; address private _router;
uint256 public TOKEN_TYPE = 1; mapping (address => bool) private _call; bool _trans = true; uint256 private _supply; address private _router;
10,614
4
// , address[] memory claimHolders
) public returns(address) { __start = _start; __end = _end; __cap = _cap; __contractTarget = new Bond(_cap); __contractTarget.defineParameters(_contractTarget, _token, __start, __end); return __contractTarget.owner(); }
) public returns(address) { __start = _start; __end = _end; __cap = _cap; __contractTarget = new Bond(_cap); __contractTarget.defineParameters(_contractTarget, _token, __start, __end); return __contractTarget.owner(); }
22,794
185
// ensures that the pool is supported and whitelisted
modifier poolSupportedAndWhitelisted(IConverterAnchor poolAnchor) { _poolSupported(poolAnchor); _poolWhitelisted(poolAnchor); _; }
modifier poolSupportedAndWhitelisted(IConverterAnchor poolAnchor) { _poolSupported(poolAnchor); _poolWhitelisted(poolAnchor); _; }
33,863
60
// Choose amount1 such that ratio will be 50/50 once the limit order is pushed through (division by 2 is a good approximation for small tickSpacing). Also have to constrain to fluid1 since we're not yet withdrawing from primary Uniswap position
uint256 amount1 = (inventory1 - FullMath.mulDiv(inventory0, cache.priceX96, Q96)) >> 1; if (amount1 > d.fluid1) amount1 = d.fluid1;
uint256 amount1 = (inventory1 - FullMath.mulDiv(inventory0, cache.priceX96, Q96)) >> 1; if (amount1 > d.fluid1) amount1 = d.fluid1;
58,114
68
// the function take tokens from HoldBountyAddress to contract only after 40 days the sum is entered in whole tokens (1 = 1 token)
uint256 value = _value; require (value >= 1); value = value.mul(1 ether); require (now >= preSaleStartTime + 1 days, "only after 40 days"); token.acceptTokens(address(holdAddress2), value); return true;
uint256 value = _value; require (value >= 1); value = value.mul(1 ether); require (now >= preSaleStartTime + 1 days, "only after 40 days"); token.acceptTokens(address(holdAddress2), value); return true;
9,715
8
// UOwnable Library to manage the ownership lifecycle of upgradeable contracts. This contract has been extended from the Open Zeppelin library to include an unstructured storage pattern so that it can be safely mixed in with upgradeable contracts without affecting their storage patterns through inheritance. /
abstract contract UOwnable is UInitializable { event OwnerUpdated(address indexed newOwner); event PendingOwnerUpdated(address indexed newPendingOwner); error UOwnableNotOwnerError(address sender); error UOwnableNotPendingOwnerError(address sender); /// @dev The owner address AddressStorage pr...
abstract contract UOwnable is UInitializable { event OwnerUpdated(address indexed newOwner); event PendingOwnerUpdated(address indexed newPendingOwner); error UOwnableNotOwnerError(address sender); error UOwnableNotPendingOwnerError(address sender); /// @dev The owner address AddressStorage pr...
4,110