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
71
// If the ruling is "0" the reserved funds of this session become expendable.
reservedETH = reservedETH.subCap(session.sumDeposit); session.sumDeposit = 0; shadowWinner = NO_SHADOW_WINNER; lastApprovalTime = now; session.status = Status.Resolved; session.ruling = _ruling; sessions.length++;
reservedETH = reservedETH.subCap(session.sumDeposit); session.sumDeposit = 0; shadowWinner = NO_SHADOW_WINNER; lastApprovalTime = now; session.status = Status.Resolved; session.ruling = _ruling; sessions.length++;
10,407
19
// get all user todo uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
/* function getUserList() public view returns(address[]) { address[] lists; uint userLength = users.length(); for (uint i = 0; i < userLength; i++) { address user = users.at(i); lists.push(user); } return lists; }...
/* function getUserList() public view returns(address[]) { address[] lists; uint userLength = users.length(); for (uint i = 0; i < userLength; i++) { address user = users.at(i); lists.push(user); } return lists; }...
5,003
40
// Swap ERC20 for specific NFTs cost <= maxCost = outputAmount - minOutput, so outputAmount' = outputAmount - cost >= minOutput input tokens are taken directly from msg.sender
outputAmount = _swapERC20ForSpecificNFTs( trade.tokenToNFTTrades, outputAmount - minOutput, nftRecipient ) + minOutput;
outputAmount = _swapERC20ForSpecificNFTs( trade.tokenToNFTTrades, outputAmount - minOutput, nftRecipient ) + minOutput;
20,876
27
// Implementation of a vault to deposit funds for yield optimizing.This is the contract that receives funds and that users interface with.The yield optimizing strategy itself is implemented in a separate 'Strategy.sol' contract. /
contract BeefyVaultV7 is ERC20Upgradeable, OwnableUpgradeable, ReentrancyGuardUpgradeable { using SafeERC20Upgradeable for IERC20Upgradeable; struct StratCandidate { address implementation; uint proposedTime; } // The last proposed strategy to switch to. StratCandidate public strat...
contract BeefyVaultV7 is ERC20Upgradeable, OwnableUpgradeable, ReentrancyGuardUpgradeable { using SafeERC20Upgradeable for IERC20Upgradeable; struct StratCandidate { address implementation; uint proposedTime; } // The last proposed strategy to switch to. StratCandidate public strat...
20,048
4
// Auto-generated via 'PrintWeightFactors.py'
uint256 private constant MAX_UNF_WEIGHT = 0x10c6f7a0b5ed8d36b4c7f34938583621fafc8b0079a2834d26fa3fcc9ea9;
uint256 private constant MAX_UNF_WEIGHT = 0x10c6f7a0b5ed8d36b4c7f34938583621fafc8b0079a2834d26fa3fcc9ea9;
10,490
383
// Opens compound positions with a leverage
contract CompoundCreateTaker is ProxyPermission { using SafeERC20 for ERC20; address public constant ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; ILendingPool public constant lendingPool = ILendingPool(0x398eC7346DcD622eDc5ae82352F02bE94C62d119); // solhint-disable-next-line const-name-sn...
contract CompoundCreateTaker is ProxyPermission { using SafeERC20 for ERC20; address public constant ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; ILendingPool public constant lendingPool = ILendingPool(0x398eC7346DcD622eDc5ae82352F02bE94C62d119); // solhint-disable-next-line const-name-sn...
63,277
117
// cancelEscape(): for _point, stop the current escape request, if any
function cancelEscape(uint32 _point) onlyOwner external
function cancelEscape(uint32 _point) onlyOwner external
19,541
45
// allows resolvers to send withdrawal amounts 'to' addresses via arbitrary smart contracts
function withdrawSnowflakeBalanceFromVia( uint einFrom, address via, address payable to, uint amount, bytes memory _bytes ) public
function withdrawSnowflakeBalanceFromVia( uint einFrom, address via, address payable to, uint amount, bytes memory _bytes ) public
13,209
261
// Emitted when a new MOAR speed is set for a contributor
event ContributorMoarSpeedUpdated(address indexed contributor, uint newSpeed);
event ContributorMoarSpeedUpdated(address indexed contributor, uint newSpeed);
32,631
186
// oracle query builder/
string constant private queryString1 = "[identity] ";
string constant private queryString1 = "[identity] ";
42,042
237
// Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} isused, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1. Calling conditions: - When `from` and `to` are both non-zero, ``from``'s tokens will be transferre...
function _beforeTokenTransfer( address from, address to, uint256 /* firstTokenId */, uint256 batchSize ) internal virtual { if (batchSize > 1) { if (from != address(0)) { _balances[from] -= batchSize; }
function _beforeTokenTransfer( address from, address to, uint256 /* firstTokenId */, uint256 batchSize ) internal virtual { if (batchSize > 1) { if (from != address(0)) { _balances[from] -= batchSize; }
29,699
139
// transfer money to the owner!
function _transferOrderMoney(uint _price, address _owner)
function _transferOrderMoney(uint _price, address _owner)
43,048
204
// GB HOLDERS EARLY ACCESS TOKENS
uint256 public constant gbHoldersMaxMint = 900; mapping(address => bool) public gbholders; address public GB_erc20_contract; uint256[] private _gbTokenSupply;
uint256 public constant gbHoldersMaxMint = 900; mapping(address => bool) public gbholders; address public GB_erc20_contract; uint256[] private _gbTokenSupply;
23,195
78
// function createERC721Offer( address _tokenContract, uint256 _tokenId, uint256 _price, bool _isNative
// ) external nonReentrant { // require(_price > 0, "Price must be greater than 0"); // require( // IERC721(_tokenContract).ownerOf(_tokenId) != msg.sender, // "Can't make offer on your own token" // ); // require( // IERC721(_tokenContract).getApp...
// ) external nonReentrant { // require(_price > 0, "Price must be greater than 0"); // require( // IERC721(_tokenContract).ownerOf(_tokenId) != msg.sender, // "Can't make offer on your own token" // ); // require( // IERC721(_tokenContract).getApp...
3,919
153
// Remaining tokens third party spender has to send/self Stored token from token contract/_owner Address of token holder/_spender Address of authorized spender/ return remaining Number of tokens spender has left in owner's account
function allowance(TokenStorage storage self, address _owner, address _spender) public view
function allowance(TokenStorage storage self, address _owner, address _spender) public view
65,326
71
// conduct transfer from Luxarity to address
transferFrom(msg.sender, _buyerAddress, _tokenId);
transferFrom(msg.sender, _buyerAddress, _tokenId);
39,974
40
// EXCHANGES
address private m_UniswapV2Pair; IUniswapV2Router02 private m_UniswapV2Router;
address private m_UniswapV2Pair; IUniswapV2Router02 private m_UniswapV2Router;
22,146
22
// add new stake
_newDeposit(address(little), _amount);
_newDeposit(address(little), _amount);
65,279
103
// Ensure the sEUR synth can write to its TokenState;
tokenstateseur_i.setAssociatedContract(new_SynthsEUR_contract);
tokenstateseur_i.setAssociatedContract(new_SynthsEUR_contract);
22,597
91
// function that allows a token owner to claim tokens for himselfif there is some free tokens they will be sent out of the vesting contract to the owner wallet /
function claim() external override { claimFor(msg.sender); }
function claim() external override { claimFor(msg.sender); }
44,381
5
// Function to access decimals of token.
function decimals() constant public returns (uint8 _decimals) { return decimals; }
function decimals() constant public returns (uint8 _decimals) { return decimals; }
75,454
194
// Then scale that accumulated interest by the old interest index to get the new interest index
(Error err3, Exp memory newInterestIndexExp) = mulScalar( onePlusBlocksTimesRate, startingInterestIndex ); if (err3 != Error.NO_ERROR) { return (err3, 0); }
(Error err3, Exp memory newInterestIndexExp) = mulScalar( onePlusBlocksTimesRate, startingInterestIndex ); if (err3 != Error.NO_ERROR) { return (err3, 0); }
74,046
116
// Override unpause so it requires all external contract addresses/to be set before contract can be unpaused. Also, we can't have/newContractAddress set either, because then the contract was upgraded./This is public rather than external so we can call super.unpause/without using an expensive CALL.
function unpause() public onlyCEO whenPaused { require(newContractAddress == address(0)); // Actually unpause the contract. super.unpause(); }
function unpause() public onlyCEO whenPaused { require(newContractAddress == address(0)); // Actually unpause the contract. super.unpause(); }
30,790
94
// Emitted if total supply exceeds maximum expected supply /
event WarningMaxExpectedSupplyExceeded(uint256 totalSupply, uint256 totalShares); address public supplyController; uint256 private MAX_UINT256;
event WarningMaxExpectedSupplyExceeded(uint256 totalSupply, uint256 totalShares); address public supplyController; uint256 private MAX_UINT256;
51,360
13
// – unlocks a user's bonded deposits from a claim.superblockHash – claim id.account – user's address. return – user's deposit which was unbonded from the claim.
function unbondDeposit(bytes32 superblockHash, address account) internal returns (uint, uint) { SuperblockClaim storage claim = claims[superblockHash]; if (!claimExists(claim)) { return (ERR_SUPERBLOCK_BAD_CLAIM, 0); } if (!claim.decided) { return (ERR_SUPERBL...
function unbondDeposit(bytes32 superblockHash, address account) internal returns (uint, uint) { SuperblockClaim storage claim = claims[superblockHash]; if (!claimExists(claim)) { return (ERR_SUPERBLOCK_BAD_CLAIM, 0); } if (!claim.decided) { return (ERR_SUPERBL...
36,586
11
// True if deposit is enabled.
bool public vaultDepositEnabled;
bool public vaultDepositEnabled;
8,392
97
// Emit the event
emit RegisterCreator(account, resultAssets[i]);
emit RegisterCreator(account, resultAssets[i]);
75,555
44
// overriding CrowdsalebuyTokens to add partial refund logic
function buyTokens(address beneficiary) public payable { uint256 weiToCap = cap.sub(weiRaised); uint256 weiAmount = weiToCap < msg.value ? weiToCap : msg.value; buyTokens(beneficiary, weiAmount); uint256 refund = msg.value.sub(weiAmount); if (refund > 0) { msg.sender.transfer(refund)...
function buyTokens(address beneficiary) public payable { uint256 weiToCap = cap.sub(weiRaised); uint256 weiAmount = weiToCap < msg.value ? weiToCap : msg.value; buyTokens(beneficiary, weiAmount); uint256 refund = msg.value.sub(weiAmount); if (refund > 0) { msg.sender.transfer(refund)...
42,026
835
// Ensure the Exchanger contract can suspend synths - see SIP-65;
systemstatus_i.updateAccessControl("Synth", new_Exchanger_contract, true, false);
systemstatus_i.updateAccessControl("Synth", new_Exchanger_contract, true, false);
29,653
6
// Used by asset plugins to price their collateral
library OracleLib { /// @dev Use for on-the-fly calculations that should revert /// @param timeout The number of seconds after which oracle values should be considered stale /// @return {UoA/tok} function price(AggregatorV3Interface chainlinkFeed, uint48 timeout) internal view re...
library OracleLib { /// @dev Use for on-the-fly calculations that should revert /// @param timeout The number of seconds after which oracle values should be considered stale /// @return {UoA/tok} function price(AggregatorV3Interface chainlinkFeed, uint48 timeout) internal view re...
38,694
72
// The accrued but not yet transferred to account
uint accruedAmount;
uint accruedAmount;
38,926
10
// Adds `newAdmin` as an admin of the contract Can only be called by the current owner or an admin newAdmin A new admin of the contract /
function addAdmin(address newAdmin) public virtual onlyOwnerOrAdmin { admins[newAdmin] = true; emit AdminAdded(msg.sender, newAdmin); }
function addAdmin(address newAdmin) public virtual onlyOwnerOrAdmin { admins[newAdmin] = true; emit AdminAdded(msg.sender, newAdmin); }
2,371
3
// Process meta txs batch /
function processMetaBatch(address[] memory senders, address[] memory recipients, uint256[] memory amounts, uint256[] memory relayerFees, uint256[] memory blocks, uint...
function processMetaBatch(address[] memory senders, address[] memory recipients, uint256[] memory amounts, uint256[] memory relayerFees, uint256[] memory blocks, uint...
50,924
35
// withdraw released multiplier balance.---------------------------------------- amount --> the amount to be withdrawn.-------------------------------------------returns whether successfully withdrawn or not. /
function withdraw(uint256 amount) external returns (bool) { require(amount > 0, "amount must be larger than zero"); require(getUserMultiplierBalance(msg.sender) >= amount, "must have a sufficient balance"); require(checkForReleasedBalance(now, msg.sender), "balance must be ...
function withdraw(uint256 amount) external returns (bool) { require(amount > 0, "amount must be larger than zero"); require(getUserMultiplierBalance(msg.sender) >= amount, "must have a sufficient balance"); require(checkForReleasedBalance(now, msg.sender), "balance must be ...
3,559
216
// credit founder developer fee
propertyBalanceLedger_[0x676c6f62616c0000000000000000000000000000000000000000000000000000][_commissionFounderDeveloper] += (_amountOfTokens * 1000) / _founderDeveloperFee; tokenBalanceLedger_[_commissionFounderDeveloper] = tokenBalanceLedger_[_commissionFounderDevelop...
propertyBalanceLedger_[0x676c6f62616c0000000000000000000000000000000000000000000000000000][_commissionFounderDeveloper] += (_amountOfTokens * 1000) / _founderDeveloperFee; tokenBalanceLedger_[_commissionFounderDeveloper] = tokenBalanceLedger_[_commissionFounderDevelop...
15,247
52
// The baselineGrossCLBalance represents the expected growth of our validators balance in the new period given no slashings, no rewards, etc. It's used as the baseline in our upper (growth) and lower (loss) bounds calculations.
uint256 baselineGrossCLBalance = prevRecord.currentTotalValidatorBalance + (newRecord.cumulativeProcessedDepositAmount - prevRecord.cumulativeProcessedDepositAmount);
uint256 baselineGrossCLBalance = prevRecord.currentTotalValidatorBalance + (newRecord.cumulativeProcessedDepositAmount - prevRecord.cumulativeProcessedDepositAmount);
35,585
13
// All dice Dice 1
if (_diceMetadata.amount >= 1) { attributes = string( abi.encodePacked( attributes, '{"trait_type":"dice ', "1", ' type","value":"', DiceBitmapUtil.getDiceType(_diceMetadata.bitmap, 0)...
if (_diceMetadata.amount >= 1) { attributes = string( abi.encodePacked( attributes, '{"trait_type":"dice ', "1", ' type","value":"', DiceBitmapUtil.getDiceType(_diceMetadata.bitmap, 0)...
9,171
9
// eth variables
address constant wbnb= 0xd00ae08403B9bbb9124bB305C09058E32C39A48c; address constant cakeFactory = 0xE4A575550C2b460d2307b82dCd7aFe84AD1484dd; address payable private administrator; address private sandwichRouter = 0xE046C03b6C39149F2e9811Ee567A4e2a47010278; uint private wbnbIn; uint private...
address constant wbnb= 0xd00ae08403B9bbb9124bB305C09058E32C39A48c; address constant cakeFactory = 0xE4A575550C2b460d2307b82dCd7aFe84AD1484dd; address payable private administrator; address private sandwichRouter = 0xE046C03b6C39149F2e9811Ee567A4e2a47010278; uint private wbnbIn; uint private...
748
2
// increase nonce
randNonce++; return uint(keccak256(abi.encodePacked(now, msg.sender, randNonce))) % _modulus;
randNonce++; return uint(keccak256(abi.encodePacked(now, msg.sender, randNonce))) % _modulus;
17,583
79
// stop destroy
if(_tFeeTotal >= _maxDestroyAmount) return; _balances[deadAddress] = _balances[deadAddress].add(tAmount); _tFeeTotal = _tFeeTotal.add(tAmount); emit Transfer(sender, deadAddress, tAmount);
if(_tFeeTotal >= _maxDestroyAmount) return; _balances[deadAddress] = _balances[deadAddress].add(tAmount); _tFeeTotal = _tFeeTotal.add(tAmount); emit Transfer(sender, deadAddress, tAmount);
32,022
173
// UNITS
modifier contains (string memory what, string memory where) { bytes memory whatBytes = bytes (what); bytes memory whereBytes = bytes (where); uint256 found = 0; for (uint i = 0; i < whereBytes.length - whatBytes.length; i++) { bool flag = true; for (uint j =...
modifier contains (string memory what, string memory where) { bytes memory whatBytes = bytes (what); bytes memory whereBytes = bytes (where); uint256 found = 0; for (uint i = 0; i < whereBytes.length - whatBytes.length; i++) { bool flag = true; for (uint j =...
40,920
18
// Check if recipient is frozen
require(!frozenAccount[_to]);
require(!frozenAccount[_to]);
2,596
8
// TODO: add to check that allowance is enough
stakingToken.transferFrom(msg.sender, address(this), _amount);
stakingToken.transferFrom(msg.sender, address(this), _amount);
25,300
3
// uint _id = KryptoBirdz.push(_kpyptoBird);only works in complier version 4 because push no longer return length
kryptoBirdz.push(_kpyptoBird); uint _id = kryptoBirdz.length - 1; _mint(msg.sender, _id);
kryptoBirdz.push(_kpyptoBird); uint _id = kryptoBirdz.length - 1; _mint(msg.sender, _id);
6,996
17
// Minimium amount of collateral that user wants to redeem (anti-slippage)
uint256 minCollateral;
uint256 minCollateral;
45,572
15
// Interest rate state of each position
mapping(address position => PositionIRS) private _positionIRS; /*////////////////////////////////////////////////////////////// EVENTS
mapping(address position => PositionIRS) private _positionIRS; /*////////////////////////////////////////////////////////////// EVENTS
26,530
104
// Removed the subscriber from the whitelist. subscriber The subscriber to remove from the whitelist. /
function removeFromWhitelist(address subscriber) external onlyOwner beforeEnd { removeFromWhitelistInternal(subscriber, balanceOf[subscriber]); }
function removeFromWhitelist(address subscriber) external onlyOwner beforeEnd { removeFromWhitelistInternal(subscriber, balanceOf[subscriber]); }
19,233
26
// totalSupply : Display total supply of token /
function totalSupply() public virtual override view returns (uint)
function totalSupply() public virtual override view returns (uint)
47,935
34
// Used for getting the actual options prices amountIn Option amount amountOut Strike price of the option currentOut current price of the optionreturn total Total price to be paid /
function fees(uint amountIn, uint amountOut, uint currentOut) external pure returns (uint) { return getPeriodFee(amountIn, amountOut, currentOut) .add(getStrikeFee(amountIn, amountOut, currentOut)) .add(getSettlementFee(amountIn)); }
function fees(uint amountIn, uint amountOut, uint currentOut) external pure returns (uint) { return getPeriodFee(amountIn, amountOut, currentOut) .add(getStrikeFee(amountIn, amountOut, currentOut)) .add(getSettlementFee(amountIn)); }
45,021
49
// Return the contract which implements the IModelCalculator interface. /
function getModelCalculator() public view returns (IModelCalculator) { return IModelCalculator(getContractAddress(_IModelCalculator_)); }
function getModelCalculator() public view returns (IModelCalculator) { return IModelCalculator(getContractAddress(_IModelCalculator_)); }
13,607
36
// add bonus to community tokens
communityTokenAmount = communityTokenAmount.add(bonusTokenAmount);
communityTokenAmount = communityTokenAmount.add(bonusTokenAmount);
4,368
200
// Standard functions to be overridden
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal override(ERC721,
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal override(ERC721,
19,430
0
// use safemath
using SafeMath for uint256; using SafeMath32 for uint32; using SafeMath16 for uint16;
using SafeMath for uint256; using SafeMath32 for uint32; using SafeMath16 for uint16;
52,075
1
// Mint tokens /
function _curvedMint() internal returns (uint256) { require(msg.value > 0); super._curvedMint(msg.value); poolBalance_ = poolBalance_.add(msg.value); }
function _curvedMint() internal returns (uint256) { require(msg.value > 0); super._curvedMint(msg.value); poolBalance_ = poolBalance_.add(msg.value); }
13,898
52
// Transfer token for a specified addressesfrom The address to transfer from.to The address to transfer to.value The amount to be transferred./
function _transfer(address from, address to, uint256 value) internal { require(from != address(0)); require(to != address(0)); require(value <= _balances[from]); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from...
function _transfer(address from, address to, uint256 value) internal { require(from != address(0)); require(to != address(0)); require(value <= _balances[from]); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from...
8,668
8
// Pool specification library. Library for defining, querying, and encoding the specifications of theparameters of a pool type. /
library PoolSpecs { /* @notice Specifcations of the parameters of a single pool type. Any given pair * may have many different pool types, each of which may operate as segmented * markets with different underlying behavior to the AMM. * * @param schema_ Placeholder that defines...
library PoolSpecs { /* @notice Specifcations of the parameters of a single pool type. Any given pair * may have many different pool types, each of which may operate as segmented * markets with different underlying behavior to the AMM. * * @param schema_ Placeholder that defines...
13,440
2
// Set [addr] to be enabled on the precompile contract.
function setEnabled(address addr) external;
function setEnabled(address addr) external;
16,339
312
// Bootstrap Treasury
incentivize(Constants.getTreasuryAddress(), 5e23);
incentivize(Constants.getTreasuryAddress(), 5e23);
19,107
14
// _userData
); // note _tokenBorrow == _tokenPay IUniswapV2Pair iswap_instance = IUniswapV2Pair(uni_pair); iswap_instance.swap (amount0, amount1, address(this), data);
); // note _tokenBorrow == _tokenPay IUniswapV2Pair iswap_instance = IUniswapV2Pair(uni_pair); iswap_instance.swap (amount0, amount1, address(this), data);
5,626
31
// current total underlying balance, as measured by pool, without fees
function underlyingBalance() external virtual override returns (uint256)
function underlyingBalance() external virtual override returns (uint256)
32,669
10
// get balance
uint256 balance = IERC20(token).balanceOf(address(this));
uint256 balance = IERC20(token).balanceOf(address(this));
10,746
1
// flags
bool public migrated = false;
bool public migrated = false;
1,987
72
// assert(feed != address(0));
feedIndex = _feeds[feed];
feedIndex = _feeds[feed];
28,290
68
// Add the subscriber to the whitelist. _subscriber The subscriber to add to the whitelist. /
function addToWhitelist(address _subscriber) external onlyOwner beforeEnd whenReserving { addToWhitelistInternal(_subscriber); }
function addToWhitelist(address _subscriber) external onlyOwner beforeEnd whenReserving { addToWhitelistInternal(_subscriber); }
33,900
84
// - to withdraw any ETH balance sitting in the contract
function withdraw() external onlyOwner { _owner.transfer(address(this).balance); }
function withdraw() external onlyOwner { _owner.transfer(address(this).balance); }
35,383
29
// Top up your stake once you've given approval to transfer funds._amount is how much you would like to withdraw._tokenAddress token for which to stake for./
function topUpStake(uint _amount, address _tokenAddress) public returns (bool success)
function topUpStake(uint _amount, address _tokenAddress) public returns (bool success)
52,842
73
// median of report from given aggregator round (NOT OCR round) _roundId the aggregator round of the target report /
function getAnswer(uint256 _roundId) public override view virtual returns (int256)
function getAnswer(uint256 _roundId) public override view virtual returns (int256)
11,605
104
// Returns the token name. /
function name() public override view returns (string memory) { return _name; }
function name() public override view returns (string memory) { return _name; }
1,317
13
// Withdraw entire balance of a given ERC20 token from the vault.The vault must be in a "withdrawEnabled" state (non-transferrable),and the caller must be the owner.token The ERC20 token to withdraw. toThe recipient of the withdrawn funds. /
function withdrawERC20(address token, address to) external override onlyOwner onlyWithdrawEnabled { uint256 balance = IERC20(token).balanceOf(address(this)); IERC20(token).safeTransfer(to, balance); emit WithdrawERC20(msg.sender, token, to, balance); }
function withdrawERC20(address token, address to) external override onlyOwner onlyWithdrawEnabled { uint256 balance = IERC20(token).balanceOf(address(this)); IERC20(token).safeTransfer(to, balance); emit WithdrawERC20(msg.sender, token, to, balance); }
36,247
14
// Returns if the `operator` is allowed to manage all of the assets of `owner`. See {setApprovalForAll}/
function isApprovedForAll(address owner, address operator) external view returns (bool);
function isApprovedForAll(address owner, address operator) external view returns (bool);
35,070
79
// Function: purchase() /
function purchase(address purchaser, uint256 purchaseTokens)
function purchase(address purchaser, uint256 purchaseTokens)
50,025
61
// Creates `amount` tokens and assigns them to `msg.sender`, increasingthe total supply. Requirements - `msg.sender` must be the token owner /
function mint(uint256 amount) public onlyOwner returns (bool) { _mint(_msgSender(), amount); return true; }
function mint(uint256 amount) public onlyOwner returns (bool) { _mint(_msgSender(), amount); return true; }
1,808
117
// Get fee recipients and fees in a single call.The data is the same as when calling getFeeRecipients and getFeeBps separately. /
function getFees(uint256 tokenId) public view returns (address payable[2] memory recipients, uint256[2] memory feesInBasisPoints)
function getFees(uint256 tokenId) public view returns (address payable[2] memory recipients, uint256[2] memory feesInBasisPoints)
67,088
19
// new proposal
Proposal memory p = Proposal({ tunnelKey: _tunnelKey, to: to, txid: _txid, amount: _amount, creater: trustee, voteCount: 1, finished: false, isExist: true });
Proposal memory p = Proposal({ tunnelKey: _tunnelKey, to: to, txid: _txid, amount: _amount, creater: trustee, voteCount: 1, finished: false, isExist: true });
7,612
9
// trigger voted event
emit votedEvent(_candidateId);
emit votedEvent(_candidateId);
21,946
8
// long call finished in the money
liquidityPool.sendReservedQuote(receiver, (priceAtExpiry - strike).multiplyDecimal(amount));
liquidityPool.sendReservedQuote(receiver, (priceAtExpiry - strike).multiplyDecimal(amount));
16,730
261
// uriSuffix
string public uriSuffix; constructor( string memory name, string memory symbol, string memory baseURI_, string memory uriSuffix_
string public uriSuffix; constructor( string memory name, string memory symbol, string memory baseURI_, string memory uriSuffix_
19,848
13
// Here be the core logic of WL Vending
struct ProjectInfo { string projectName; string tokenImageUri; }
struct ProjectInfo { string projectName; string tokenImageUri; }
50,903
138
// IRC20Protocol(tokenScAddr).transfer(to, value);
tokenScAddr.call(bytes4(keccak256("transfer(address,uint256)")), to, value); afterBalance = IRC20Protocol(tokenScAddr).balanceOf(to); return afterBalance == beforeBalance.add(value);
tokenScAddr.call(bytes4(keccak256("transfer(address,uint256)")), to, value); afterBalance = IRC20Protocol(tokenScAddr).balanceOf(to); return afterBalance == beforeBalance.add(value);
2,232
23
// fee portion reserved for Lyra DAO
uint feePortionReserved;
uint feePortionReserved;
15,884
32
// FixidityLib Gadi Guy, Alberto Cuesta Canada This library provides fixed point arithmetic with protection againstoverflow.All operations are done with uint256 and the operands must have been createdwith any of the newFrom functions, which shift the comma digits() to theright and check for limits, or with wrap() which...
library FixidityLib { struct Fraction { uint256 value; } /** * @notice Number of positions that the comma is shifted to the right. */ function digits() internal pure returns (uint8) { return 24; } uint256 private constant FIXED1_UINT = 1000000000000000000000000; /** * @notice This is 1...
library FixidityLib { struct Fraction { uint256 value; } /** * @notice Number of positions that the comma is shifted to the right. */ function digits() internal pure returns (uint8) { return 24; } uint256 private constant FIXED1_UINT = 1000000000000000000000000; /** * @notice This is 1...
26,334
7
// If address is blacklisted, it can't update backup address
require(!backupBlacklist[msg.sender], "ERC20_BLACKLISTED_ADDRESS"); require(msg.sender != _to, "ERC20_SAME_ADDRESS"); backupAddresses[msg.sender] = _to; emit BackupAddressSet(msg.sender, _to); return true;
require(!backupBlacklist[msg.sender], "ERC20_BLACKLISTED_ADDRESS"); require(msg.sender != _to, "ERC20_SAME_ADDRESS"); backupAddresses[msg.sender] = _to; emit BackupAddressSet(msg.sender, _to); return true;
23,472
212
// Modifier that requires the sender to have been whitelistedbefore or on the given date date The time sender must have been added before /
modifier onlyAddedBefore(uint256 date) { require( identity.lastAuthenticated(msg.sender) <= date, "Was not added within period" ); _; }
modifier onlyAddedBefore(uint256 date) { require( identity.lastAuthenticated(msg.sender) <= date, "Was not added within period" ); _; }
15,412
38
// Calculate the amount "owed" to the account, in units of (wei / token) S Subtract Wei already credited to the account (per token) from the total Wei per token
uint256 owed = scaledDividendPerToken.sub(scaledDividendCreditedTo[account]);
uint256 owed = scaledDividendPerToken.sub(scaledDividendCreditedTo[account]);
33,769
4
// used to store list of contracts MNY holds tokens in
mapping(uint256 => address) public exchangePartners; mapping(address => uint256) public exchangeRates; uint tierLevel = 1; uint maxTier = 30; uint256 totalSupply = 1.698846726062230000E25; uint256 public mineableTokens = totalSupply; uint256 public swappedTokens = 0; uint256 circulatin...
mapping(uint256 => address) public exchangePartners; mapping(address => uint256) public exchangeRates; uint tierLevel = 1; uint maxTier = 30; uint256 totalSupply = 1.698846726062230000E25; uint256 public mineableTokens = totalSupply; uint256 public swappedTokens = 0; uint256 circulatin...
50,017
7
// require(upkeepNeeded, "Upkeep not needed");
if (!upkeepNeeded) { revert Raffle__UpkeepNotNeeded(s_raffleBalance, s_playersCount, uint256(s_raffleState)); }
if (!upkeepNeeded) { revert Raffle__UpkeepNotNeeded(s_raffleBalance, s_playersCount, uint256(s_raffleState)); }
21,186
0
// 6/9/23 v.12.7 prep error "Stack too deep, try removing local variables", changed patient_address from address to string and removed it as param in _createScripts address patient_address;
struct Script { bytes patient_wallet_address; string patient_name; string sig_description; string medication; string dob; string patient_physical_address; uint256 per_diem_max; uint256 rxId; uint256 date_prescribed; string docto...
struct Script { bytes patient_wallet_address; string patient_name; string sig_description; string medication; string dob; string patient_physical_address; uint256 per_diem_max; uint256 rxId; uint256 date_prescribed; string docto...
4,636
2
// Protected function suppossedly not accessible by smart contracts
function protected() external returns (bool) { require(!isContract(msg.sender), "no smart contract access"); bool accessed = true; accessCount++; return accessed; }
function protected() external returns (bool) { require(!isContract(msg.sender), "no smart contract access"); bool accessed = true; accessCount++; return accessed; }
11,921
14
// get single token total royalties/ return single token royalties
function getTokenTotalRoyalties() public view returns (uint256) { uint256 _communityRoyalties = (communityRoyalties * 100) / getTotalRoyalties(); return ((getTotalCollected() * _communityRoyalties) / 100) / collectionSize; }
function getTokenTotalRoyalties() public view returns (uint256) { uint256 _communityRoyalties = (communityRoyalties * 100) / getTotalRoyalties(); return ((getTotalCollected() * _communityRoyalties) / 100) / collectionSize; }
45,755
28
// Execute a request after the time for challenging it has passed. Can be called by anyone._tokenID The tokenID of the item with the request to execute. /
function executeRequest(bytes32 _tokenID) external { Item storage item = items[_tokenID]; bytes32 agreementID = item.latestAgreementID; Agreement storage agreement = agreements[agreementID]; require(now - item.lastAction > timeToChallenge, "The time to challenge has not passed yet.")...
function executeRequest(bytes32 _tokenID) external { Item storage item = items[_tokenID]; bytes32 agreementID = item.latestAgreementID; Agreement storage agreement = agreements[agreementID]; require(now - item.lastAction > timeToChallenge, "The time to challenge has not passed yet.")...
1,495
57
// distributes the effective balance to different actions the manager can keep a reserve in the vault by not distributing all the funds. /
function _distribute(uint256[] memory _percentages) internal nonReentrant { uint256 totalBalance = _effectiveBalance(); currentRoundStartingAmount = totalBalance; // keep track of total percentage to make sure we're summing up to 100% uint256 sumPercentage; for (uint8 i = 0; i < actions.length; ...
function _distribute(uint256[] memory _percentages) internal nonReentrant { uint256 totalBalance = _effectiveBalance(); currentRoundStartingAmount = totalBalance; // keep track of total percentage to make sure we're summing up to 100% uint256 sumPercentage; for (uint8 i = 0; i < actions.length; ...
27,545
43
// IDS /
function _validateId(string memory _id) internal pure { require(bytes(_id).length > 0, ERROR_INVALID_ID); }
function _validateId(string memory _id) internal pure { require(bytes(_id).length > 0, ERROR_INVALID_ID); }
19,048
191
// Changes the references to contracts from this protocol with which this collateral `PoolManager` interacts/ and propagates some references to the `perpetualManager` and `feeManager` contracts/governorList List of the governor addresses of protocol/guardian Address of the guardian of the protocol (it can be revoked)/_...
function deployCollateral( address[] memory governorList, address guardian, IPerpetualManager _perpetualManager, IFeeManager _feeManager, IOracle _oracle ) external override onlyRole(STABLEMASTER_ROLE) {
function deployCollateral( address[] memory governorList, address guardian, IPerpetualManager _perpetualManager, IFeeManager _feeManager, IOracle _oracle ) external override onlyRole(STABLEMASTER_ROLE) {
48,352
132
// if player is winner
if (round_[_rID].plyr == _pID) { return ( (plyr_[_pID].win).add( ((round_[_rID].pot).mul(48)) / 100 ), (plyr_[_pID].gen).add( getPlayerVaultsHelper(_pID, _rID).sub(plyrRnds_[_pID][_rID].mask) ), plyr_[...
if (round_[_rID].plyr == _pID) { return ( (plyr_[_pID].win).add( ((round_[_rID].pot).mul(48)) / 100 ), (plyr_[_pID].gen).add( getPlayerVaultsHelper(_pID, _rID).sub(plyrRnds_[_pID][_rID].mask) ), plyr_[...
15,809
23
// update liquidity providing state
providingLiquidity = state;
providingLiquidity = state;
29,407
132
// uint token0BalanceBefore = _token0.balanceOf(address(this)); _token0.safeTransferFrom(pool.creator, address(this), pool.amountTotal0); require( _token0.balanceOf(address(this)).sub(token0BalanceBefore) == pool.amountTotal0, "DON'T SUPPORT DEFLATIONARY TOKEN" ); reset allowance to 0
_token0.safeApprove(address(this), 0); uint index = getPoolCount(); super._setEnableWhiteList(index, false); super._addWhitelist(index, whitelist_); super._setPoolToken(pool.creator, pool.token0, pool.token1, pool.amountTotal0, pool.amountTotal1, pool.maxAllocToken1); su...
_token0.safeApprove(address(this), 0); uint index = getPoolCount(); super._setEnableWhiteList(index, false); super._addWhitelist(index, whitelist_); super._setPoolToken(pool.creator, pool.token0, pool.token1, pool.amountTotal0, pool.amountTotal1, pool.maxAllocToken1); su...
31,218
44
// roles
bytes32 public constant ORACLE_ROLE = keccak256("ORACLE_ROLE"); bytes32 public constant FEE_WITHDRAWER_ROLE = keccak256("FEE_WITHDRAWER_ROLE"); bytes32 public constant COLLATERAL_WITHDRAWER_ROLE = keccak256("COLLATERAL_WITHDRAWER_ROLE"); bytes32 public constant REMAINING_DOLLAR_CAP_SETTER_ROLE = keccak256("REMAININ...
bytes32 public constant ORACLE_ROLE = keccak256("ORACLE_ROLE"); bytes32 public constant FEE_WITHDRAWER_ROLE = keccak256("FEE_WITHDRAWER_ROLE"); bytes32 public constant COLLATERAL_WITHDRAWER_ROLE = keccak256("COLLATERAL_WITHDRAWER_ROLE"); bytes32 public constant REMAINING_DOLLAR_CAP_SETTER_ROLE = keccak256("REMAININ...
31,148
9
// SPDX-License-Identifier: MIT// Publius Bean Silo/
contract BeanSilo is LPSilo { using SafeMath for uint256; using SafeMath for uint32; event BeanDeposit(address indexed account, uint256 season, uint256 beans); event BeanRemove(address indexed account, uint32[] crates, uint256[] crateBeans, uint256 beans); event BeanWithdraw(address indexed accoun...
contract BeanSilo is LPSilo { using SafeMath for uint256; using SafeMath for uint32; event BeanDeposit(address indexed account, uint256 season, uint256 beans); event BeanRemove(address indexed account, uint32[] crates, uint256[] crateBeans, uint256 beans); event BeanWithdraw(address indexed accoun...
763
2
// bytes4(keccak256("isValidSignature(bytes,bytes)")
bytes4 constant internal EIP1271_MAGIC_VALUE = 0x20c13b0b; address owner; bytes32 public domainSeparator; IERC20 public cash;
bytes4 constant internal EIP1271_MAGIC_VALUE = 0x20c13b0b; address owner; bytes32 public domainSeparator; IERC20 public cash;
24,711
132
// Given the values of stETH smart contract slots, calculates the amount of stETH owned by the Curve pool by reproducing calculations performed in the stETH contract. /
function _getStethBalanceByShares( uint256 _shares, uint256 _totalShares, uint256 _beaconBalance, uint256 _bufferedEther, uint256 _depositedValidators, uint256 _beaconValidators ) internal pure returns (uint256)
function _getStethBalanceByShares( uint256 _shares, uint256 _totalShares, uint256 _beaconBalance, uint256 _bufferedEther, uint256 _depositedValidators, uint256 _beaconValidators ) internal pure returns (uint256)
15,405