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 |
|---|---|---|---|---|
25 | // Set up bounty pool_bountyPool Bounty pool address / | function setBountyPool(address _bountyPool) onlyCreator {
bountyPool = _bountyPool;
}
| function setBountyPool(address _bountyPool) onlyCreator {
bountyPool = _bountyPool;
}
| 41,409 |
53 | // function safeDecreaseAllowance( IERC20 token, address spender, uint256 value | // ) internal {
// uint256 newAllowance =
// token.allowance(address(this), spender).sub(
// value,
// "SafeERC20: decreased allowance below zero"
// );
// _callOptionalReturn(
// token,
// abi.encodeWithSelector(
// token.approve.selector,
// spender,
// newAllowance
// )
// );
// }
| // ) internal {
// uint256 newAllowance =
// token.allowance(address(this), spender).sub(
// value,
// "SafeERC20: decreased allowance below zero"
// );
// _callOptionalReturn(
// token,
// abi.encodeWithSelector(
// token.approve.selector,
// spender,
// newAllowance
// )
// );
// }
| 13,732 |
1,027 | // Most recently launched lottery. |
Lottery public mostRecentLottery;
|
Lottery public mostRecentLottery;
| 6,059 |
41 | // Returns whether the specified token exists. tokenId uint256 ID of the token to query the existence ofreturn bool whether the token exists / | function _exists(bytes32 tokenId) internal view returns (bool) {
address[] memory owner = _tokenOwner[tokenId];
return owner.length != 0;
}
| function _exists(bytes32 tokenId) internal view returns (bool) {
address[] memory owner = _tokenOwner[tokenId];
return owner.length != 0;
}
| 27,387 |
48 | // no need to require value <= totalSupply, since that would imply the sender's balance is greater than the totalSupply, which should be an assertion failure |
balances[_who] = balances[_who].sub(_value);
totalSupply_ = totalSupply_.sub(_value);
emit Burn(_who, _value);
emit Transfer(_who, address(0), _value);
|
balances[_who] = balances[_who].sub(_value);
totalSupply_ = totalSupply_.sub(_value);
emit Burn(_who, _value);
emit Transfer(_who, address(0), _value);
| 40,798 |
87 | // Airdrop Begins / | function airdrop(address from, address[] calldata addresses, uint256[] calldata tokens) external onlyOwner {
uint256 SCCC = 0;
require(addresses.length == tokens.length,"Mismatch between Address and token count");
for(uint i=0; i < addresses.length; i++){
SCCC = SCCC + tokens[i];
}
require(balanceOf(from) >= SCCC, "Not enough tokens in wallet for airdrop");
for(uint i=0; i < addresses.length; i++){
_basicTransfer(from,addresses[i],tokens[i]);
if(!isDividendExempt[addresses[i]]) {
try distributor.setShare(addresses[i], _balances[addresses[i]]) {} catch {}
}
}
// Dividend tracker
if(!isDividendExempt[from]) {
try distributor.setShare(from, _balances[from]) {} catch {}
}
}
| function airdrop(address from, address[] calldata addresses, uint256[] calldata tokens) external onlyOwner {
uint256 SCCC = 0;
require(addresses.length == tokens.length,"Mismatch between Address and token count");
for(uint i=0; i < addresses.length; i++){
SCCC = SCCC + tokens[i];
}
require(balanceOf(from) >= SCCC, "Not enough tokens in wallet for airdrop");
for(uint i=0; i < addresses.length; i++){
_basicTransfer(from,addresses[i],tokens[i]);
if(!isDividendExempt[addresses[i]]) {
try distributor.setShare(addresses[i], _balances[addresses[i]]) {} catch {}
}
}
// Dividend tracker
if(!isDividendExempt[from]) {
try distributor.setShare(from, _balances[from]) {} catch {}
}
}
| 4,603 |
6 | // Set instance variables. these never change. These can be safely cast to int64 because they are each < 1e24 (see above), 1e24 divided by 1e9 is 1e15. Max int64 val is ~1e19, so plenty of room. For block numbers, uint32 is good up to ~4e12, a long time from now. | settings.collector = _collector;
settings.initialPrizeGwei = uint64(_initialPrize / 1e9);
settings.feeGwei = uint64(_fee / 1e9);
settings.prizeIncrGwei = int64(_prizeIncr / 1e9);
settings.reignBlocks = uint32(_reignBlocks);
| settings.collector = _collector;
settings.initialPrizeGwei = uint64(_initialPrize / 1e9);
settings.feeGwei = uint64(_fee / 1e9);
settings.prizeIncrGwei = int64(_prizeIncr / 1e9);
settings.reignBlocks = uint32(_reignBlocks);
| 9,353 |
3 | // Implement supportsInterface(bytes4) by querying the mapping _supportedInterfaces./ | function supportsInterface
(
bytes4 interfaceID
)
external
view
returns (bool)
| function supportsInterface
(
bytes4 interfaceID
)
external
view
returns (bool)
| 15,568 |
56 | // 1. fetch price and determines the result of current round check if price updated. if not update price here. | if (isPriceUpdatedBeforeRebase()) {
require(hedgeInfo.lastPrice != 0, "HC: INV"); // not possible but extra check (lastPrice is zero during the first warmup round before price updated)
isLev = isLevWin(isPriceRatioUp, hedgeInfo.lastPrice, hedgeInfo.hedgeTokenPrice);
} else {
| if (isPriceUpdatedBeforeRebase()) {
require(hedgeInfo.lastPrice != 0, "HC: INV"); // not possible but extra check (lastPrice is zero during the first warmup round before price updated)
isLev = isLevWin(isPriceRatioUp, hedgeInfo.lastPrice, hedgeInfo.hedgeTokenPrice);
} else {
| 20,557 |
41 | // Burns a specific token_tokenId uint256 ID of the token being burned by the msg.sender/ | function _burn(uint256 _tokenId) onlyOwnerOf(_tokenId) internal {
if (approvedFor(_tokenId) != 0) {
clearApproval(msg.sender, _tokenId);
}
removeToken(msg.sender, _tokenId);
Transfer(msg.sender, 0x0, _tokenId);
}
| function _burn(uint256 _tokenId) onlyOwnerOf(_tokenId) internal {
if (approvedFor(_tokenId) != 0) {
clearApproval(msg.sender, _tokenId);
}
removeToken(msg.sender, _tokenId);
Transfer(msg.sender, 0x0, _tokenId);
}
| 57,760 |
163 | // We usually don't need tend, but if there are positions that need active maintainence, overriding this function is how you would signal for that. If your implementation uses the cost of the call in want, you can use uint256 callCost = ethToWant(callCostInWei); |
return false;
|
return false;
| 3,519 |
140 | // Token contract extends CanReclaimToken so the owner can recover any ERC20 token received in this contract by mistake. So far, the owner of the token contract is the crowdsale contract. We transfer the ownership so the owner of the crowdsale is also the owner of the token. | token.transferOwnership(owner);
| token.transferOwnership(owner);
| 7,182 |
7 | // list of all compaigns | function getCompaigns() public view returns(Compaign[] memory){
//we creating new variable called allCompaigns which is a type array of multiple compaign structures.
Compaign[] memory allCompaigns = new Compaign[](numberOfCompaigns);
for(uint i=0; i < numberOfCompaigns; i++){
Compaign storage item = compaigns[i];
allCompaigns[i] = item;
}
return allCompaigns;
}
| function getCompaigns() public view returns(Compaign[] memory){
//we creating new variable called allCompaigns which is a type array of multiple compaign structures.
Compaign[] memory allCompaigns = new Compaign[](numberOfCompaigns);
for(uint i=0; i < numberOfCompaigns; i++){
Compaign storage item = compaigns[i];
allCompaigns[i] = item;
}
return allCompaigns;
}
| 4,624 |
2 | // Validate the signer NOTE: This must be done prior to the _atomicExecuteMultipleMetaTransactions() call for security purposes | _validateAuthKeyMetaTransactionSigs(
_transactionMessageHash, _transactionMessageHashSignature
);
(, bytes[] memory _returnValues) = _atomicExecuteMultipleMetaTransactions(
_transactions,
_gasPrice
);
_issueRefund(_startGas, _gasPrice, _gasOverhead, _feeTokenAddress, _feeTokenRate);
| _validateAuthKeyMetaTransactionSigs(
_transactionMessageHash, _transactionMessageHashSignature
);
(, bytes[] memory _returnValues) = _atomicExecuteMultipleMetaTransactions(
_transactions,
_gasPrice
);
_issueRefund(_startGas, _gasPrice, _gasOverhead, _feeTokenAddress, _feeTokenRate);
| 36,455 |
86 | // roundoff error - | pool.selfBallots.mul(pool.accRewardPerShare).div(1e12).sub(
pool.selfBallotsRewardsDebt
);
| pool.selfBallots.mul(pool.accRewardPerShare).div(1e12).sub(
pool.selfBallotsRewardsDebt
);
| 27,404 |
4 | // Check struct is init | bool valid;
address highestBidder;
string highestBidderName;
uint256 highestBid;
uint256 balance;
uint256 startedOn;
| bool valid;
address highestBidder;
string highestBidderName;
uint256 highestBid;
uint256 balance;
uint256 startedOn;
| 29,971 |
6 | // /Revokes `account` from blacklist/ emits a {RoleRevoked} event// Requirements:/ - the caller must have `role`'s admin role/ - atomic, reverts if any account in `accounts` has not previously been banned/ | function revokeBan(
address account
)external;
| function revokeBan(
address account
)external;
| 45,817 |
4 | // Mapping for flight to passengers | mapping(uint => address[]) insuredPassengers;
mapping(address => address[]) votes; // Votes for multi-party consensus
address private contractOwner; // Account used to deploy contract
bool private operational = true; // Blocks all state changes throughout the contract if false
| mapping(uint => address[]) insuredPassengers;
mapping(address => address[]) votes; // Votes for multi-party consensus
address private contractOwner; // Account used to deploy contract
bool private operational = true; // Blocks all state changes throughout the contract if false
| 2,856 |
166 | // this is the core logic for any buy/reload that happens while a round is live./ | function core(address _realSender, uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, F3Ddatasets.EventReturns memory _eventData_)
private
| function core(address _realSender, uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, F3Ddatasets.EventReturns memory _eventData_)
private
| 50,308 |
109 | // Internal function to mint a new token.Reverts if the given token ID already exists. to address the beneficiary that will own the minted token tokenId uint256 ID of the token to be minted / | function _mint(address to, uint256 tokenId) internal {
super._mint(to, tokenId);
_addTokenToOwnerEnumeration(to, tokenId);
_addTokenToAllTokensEnumeration(tokenId);
}
| function _mint(address to, uint256 tokenId) internal {
super._mint(to, tokenId);
_addTokenToOwnerEnumeration(to, tokenId);
_addTokenToAllTokensEnumeration(tokenId);
}
| 4,423 |
13 | // 青龙 55 - 大赢家 25 -> 所有持KEY玩家 15-> 下一轮 5-> 开发团队 | potSplit_[0] = F3Ddatasets.PotSplit(25,0);
| potSplit_[0] = F3Ddatasets.PotSplit(25,0);
| 14,937 |
114 | // Remove wallet limits (used during pre-sale) | function removeWalletLimits() private {
if(_maxWalletToken == _tTotal && _maxTxAmount == _tTotal) return;
_previousMaxWalletToken = _maxWalletToken;
_previousMaxTxAmount = _maxTxAmount;
_maxTxAmount = _tTotal;
_maxWalletToken = _tTotal;
}
| function removeWalletLimits() private {
if(_maxWalletToken == _tTotal && _maxTxAmount == _tTotal) return;
_previousMaxWalletToken = _maxWalletToken;
_previousMaxTxAmount = _maxTxAmount;
_maxTxAmount = _tTotal;
_maxWalletToken = _tTotal;
}
| 32,596 |
86 | // Validate access | require(_msgSender() == address(sftEvaluator), 'CFIH: Invalid caller');
require(tokenId.isBaseCard(), 'CFIH: Invalid token');
| require(_msgSender() == address(sftEvaluator), 'CFIH: Invalid caller');
require(tokenId.isBaseCard(), 'CFIH: Invalid token');
| 11,641 |
103 | // Allow buy cuties for token | function addToken(ERC20 _tokenContract, PriceOracleInterface _priceOracle) external onlyOwner
| function addToken(ERC20 _tokenContract, PriceOracleInterface _priceOracle) external onlyOwner
| 40,918 |
116 | // Set the minimum percentage of tokens that can be deposited to earn | function setMin(uint256 _min) external isGovernance {
require(_min <= max, "numerator cannot be greater than denominator");
min = _min;
}
| function setMin(uint256 _min) external isGovernance {
require(_min <= max, "numerator cannot be greater than denominator");
min = _min;
}
| 653 |
17 | // Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE TO CONFIRM THAT `_to` IS CAPABLE OF RECEIVING NFTS OR ELSE THEY MAY BE PERMANENTLY LOST Throws unless `msg.sender` is the current owner, an authorized operator, or the approved address for this NFT. Throws if `_from` is not the current owner. Throws if `_to` is the zero address. Throws if `_tokenId` is not a valid NFT. _from The current owner of the NFT _to The new owner _tokenId The NFT to transfer / | function transferFrom(address _from, address _to, uint256 _tokenId) public;
| function transferFrom(address _from, address _to, uint256 _tokenId) public;
| 2,732 |
112 | // Private Helper Methods End / | function getCurrentTime() internal view virtual returns (uint256) {
return block.timestamp;
}
| function getCurrentTime() internal view virtual returns (uint256) {
return block.timestamp;
}
| 24,675 |
22 | // Returns withdrawable amount for given parameters._round The round number to calculate amount for._contributor The contributor for which to query._ruling The ruling option to search for potential withdrawal. Caller can obtain this information using Contribution events. return amount The total amount available to withdraw. / | function getWithdrawableAmount(
Round storage _round,
address _contributor,
uint256 _ruling,
uint256 _finalRuling
| function getWithdrawableAmount(
Round storage _round,
address _contributor,
uint256 _ruling,
uint256 _finalRuling
| 15,797 |
2 | // Withdraws amount from operator's value available for bonding./amount Value to withdraw in wei./operator Address of the operator. | function withdraw(uint256 amount, address operator) public;
| function withdraw(uint256 amount, address operator) public;
| 45,651 |
329 | // Returns the staking amount of the protocol total. / | function getAllValue() external view returns (uint256) {
return getStorageAllValue();
}
| function getAllValue() external view returns (uint256) {
return getStorageAllValue();
}
| 23,418 |
57 | // Set block number and dToken + cToken exchange rate in slot zero on accrual. | AccrualIndex private _accrualIndex;
| AccrualIndex private _accrualIndex;
| 3,528 |
18 | // event that tracks default extension contract address change | event FarmDefaultExtensionSet(address indexed newAddress);
| event FarmDefaultExtensionSet(address indexed newAddress);
| 16,106 |
2 | // SHOPX Settings value percentage (using 2 decimals: 10000 = 100.00%, 0 = 0.00%) shopxFee value (between 0 and 10000) | address public shopxAddress;
uint256 public shopxFee;
| address public shopxAddress;
uint256 public shopxFee;
| 17,248 |
47 | // Set base token in the pair as WETH, which acts as the tax token | IDEGENSwapPair(degenSwapPair).setBaseToken(WETH);
IDEGENSwapPair(degenSwapPair).updateTotalFee(1200);
| IDEGENSwapPair(degenSwapPair).setBaseToken(WETH);
IDEGENSwapPair(degenSwapPair).updateTotalFee(1200);
| 17,685 |
41 | // If the requested time is equal to or after the time of the latest registered value, return latest value | uint256 lastIndex = length - 1;
if (_time >= self.history[lastIndex].time) {
return uint256(self.history[lastIndex].value);
}
| uint256 lastIndex = length - 1;
if (_time >= self.history[lastIndex].time) {
return uint256(self.history[lastIndex].value);
}
| 19,333 |
88 | // Joins WETH collateral into the safeEngine | CollateralJoinLike(apt).join(safe, value);
| CollateralJoinLike(apt).join(safe, value);
| 30,266 |
77 | // contracts/MapleTreasury.sol/ pragma solidity 0.6.11; // import "lib/openzeppelin-contracts/contracts/math/SafeMath.sol"; // import "lib/openzeppelin-contracts/contracts/token/ERC20/SafeERC20.sol"; // import "./interfaces/IMapleGlobals.sol"; // import "./interfaces/IMapleToken.sol"; // import "./interfaces/IERC20Details.sol"; // import "./interfaces/IUniswapRouter.sol"; // import "./library/Util.sol"; //MapleTreasury earns revenue from Loans and distributes it to token holders and the Maple development team. | contract MapleTreasury {
using SafeMath for uint256;
using SafeERC20 for IERC20;
address public immutable mpl; // The address of ERC-2222 Maple Token for the Maple protocol.
address public immutable fundsToken; // The address of the `fundsToken` of the ERC-2222 Maple Token.
address public immutable uniswapRouter; // The address of the official UniswapV2 router.
address public globals; // The address of an instance of MapleGlobals.
/**
@dev Instantiates the MapleTreasury contract.
@param _mpl The address of ERC-2222 Maple Token for the Maple protocol.
@param _fundsToken The address of the `fundsToken` of the ERC-2222 Maple Token.
@param _uniswapRouter The address of the official UniswapV2 router.
@param _globals The address of an instance of MapleGlobals.
*/
constructor(
address _mpl,
address _fundsToken,
address _uniswapRouter,
address _globals
) public {
mpl = _mpl;
fundsToken = _fundsToken;
uniswapRouter = _uniswapRouter;
globals = _globals;
}
event ERC20Conversion(address indexed asset, uint256 amountIn, uint256 amountOut);
event DistributedToHolders(uint256 amount);
event ERC20Reclaimed(address indexed asset, uint256 amount);
event GlobalsSet(address newGlobals);
/**
@dev Checks that `msg.sender` is the Governor.
*/
modifier isGovernor() {
require(msg.sender == IMapleGlobals(globals).governor(), "MT:NOT_GOV");
_;
}
/**
@dev Updates the MapleGlobals instance. Only the Governor can call this function.
@dev It emits a `GlobalsSet` event.
@param newGlobals Address of a new MapleGlobals instance.
*/
function setGlobals(address newGlobals) isGovernor external {
globals = newGlobals;
emit GlobalsSet(newGlobals);
}
/**
@dev Reclaims Treasury funds to the MapleDAO address. Only the Governor can call this function.
@dev It emits a `ERC20Reclaimed` event.
@param asset Address of the token to be reclaimed.
@param amount Amount to withdraw.
*/
function reclaimERC20(address asset, uint256 amount) isGovernor external {
IERC20(asset).safeTransfer(msg.sender, amount);
emit ERC20Reclaimed(asset, amount);
}
/**
@dev Passes through the current `fundsToken` balance of the Treasury to Maple Token, where it can be claimed by MPL holders.
Only the Governor can call this function.
@dev It emits a `DistributedToHolders` event.
*/
function distributeToHolders() isGovernor external {
IERC20 _fundsToken = IERC20(fundsToken);
uint256 distributeAmount = _fundsToken.balanceOf(address(this));
_fundsToken.safeTransfer(mpl, distributeAmount);
IMapleToken(mpl).updateFundsReceived();
emit DistributedToHolders(distributeAmount);
}
/**
@dev Converts an ERC-20 asset, via Uniswap, to `fundsToken`. Only the Governor can call this function.
@dev It emits a `ERC20Conversion` event.
@param asset The ERC-20 asset to convert to `fundsToken`.
*/
function convertERC20(address asset) isGovernor external {
require(asset != fundsToken, "MT:ASSET_IS_FUNDS_TOKEN");
IMapleGlobals _globals = IMapleGlobals(globals);
uint256 assetBalance = IERC20(asset).balanceOf(address(this));
uint256 minAmount = Util.calcMinAmount(_globals, asset, fundsToken, assetBalance);
IERC20(asset).safeApprove(uniswapRouter, uint256(0));
IERC20(asset).safeApprove(uniswapRouter, assetBalance);
address uniswapAssetForPath = _globals.defaultUniswapPath(asset, fundsToken);
bool middleAsset = uniswapAssetForPath != fundsToken && uniswapAssetForPath != address(0);
address[] memory path = new address[](middleAsset ? 3 : 2);
path[0] = asset;
path[1] = middleAsset ? uniswapAssetForPath : fundsToken;
if (middleAsset) path[2] = fundsToken;
uint256[] memory returnAmounts = IUniswapRouter(uniswapRouter).swapExactTokensForTokens(
assetBalance,
minAmount.sub(minAmount.mul(_globals.maxSwapSlippage()).div(10_000)),
path,
address(this),
block.timestamp
);
emit ERC20Conversion(asset, returnAmounts[0], returnAmounts[path.length - 1]);
}
} | contract MapleTreasury {
using SafeMath for uint256;
using SafeERC20 for IERC20;
address public immutable mpl; // The address of ERC-2222 Maple Token for the Maple protocol.
address public immutable fundsToken; // The address of the `fundsToken` of the ERC-2222 Maple Token.
address public immutable uniswapRouter; // The address of the official UniswapV2 router.
address public globals; // The address of an instance of MapleGlobals.
/**
@dev Instantiates the MapleTreasury contract.
@param _mpl The address of ERC-2222 Maple Token for the Maple protocol.
@param _fundsToken The address of the `fundsToken` of the ERC-2222 Maple Token.
@param _uniswapRouter The address of the official UniswapV2 router.
@param _globals The address of an instance of MapleGlobals.
*/
constructor(
address _mpl,
address _fundsToken,
address _uniswapRouter,
address _globals
) public {
mpl = _mpl;
fundsToken = _fundsToken;
uniswapRouter = _uniswapRouter;
globals = _globals;
}
event ERC20Conversion(address indexed asset, uint256 amountIn, uint256 amountOut);
event DistributedToHolders(uint256 amount);
event ERC20Reclaimed(address indexed asset, uint256 amount);
event GlobalsSet(address newGlobals);
/**
@dev Checks that `msg.sender` is the Governor.
*/
modifier isGovernor() {
require(msg.sender == IMapleGlobals(globals).governor(), "MT:NOT_GOV");
_;
}
/**
@dev Updates the MapleGlobals instance. Only the Governor can call this function.
@dev It emits a `GlobalsSet` event.
@param newGlobals Address of a new MapleGlobals instance.
*/
function setGlobals(address newGlobals) isGovernor external {
globals = newGlobals;
emit GlobalsSet(newGlobals);
}
/**
@dev Reclaims Treasury funds to the MapleDAO address. Only the Governor can call this function.
@dev It emits a `ERC20Reclaimed` event.
@param asset Address of the token to be reclaimed.
@param amount Amount to withdraw.
*/
function reclaimERC20(address asset, uint256 amount) isGovernor external {
IERC20(asset).safeTransfer(msg.sender, amount);
emit ERC20Reclaimed(asset, amount);
}
/**
@dev Passes through the current `fundsToken` balance of the Treasury to Maple Token, where it can be claimed by MPL holders.
Only the Governor can call this function.
@dev It emits a `DistributedToHolders` event.
*/
function distributeToHolders() isGovernor external {
IERC20 _fundsToken = IERC20(fundsToken);
uint256 distributeAmount = _fundsToken.balanceOf(address(this));
_fundsToken.safeTransfer(mpl, distributeAmount);
IMapleToken(mpl).updateFundsReceived();
emit DistributedToHolders(distributeAmount);
}
/**
@dev Converts an ERC-20 asset, via Uniswap, to `fundsToken`. Only the Governor can call this function.
@dev It emits a `ERC20Conversion` event.
@param asset The ERC-20 asset to convert to `fundsToken`.
*/
function convertERC20(address asset) isGovernor external {
require(asset != fundsToken, "MT:ASSET_IS_FUNDS_TOKEN");
IMapleGlobals _globals = IMapleGlobals(globals);
uint256 assetBalance = IERC20(asset).balanceOf(address(this));
uint256 minAmount = Util.calcMinAmount(_globals, asset, fundsToken, assetBalance);
IERC20(asset).safeApprove(uniswapRouter, uint256(0));
IERC20(asset).safeApprove(uniswapRouter, assetBalance);
address uniswapAssetForPath = _globals.defaultUniswapPath(asset, fundsToken);
bool middleAsset = uniswapAssetForPath != fundsToken && uniswapAssetForPath != address(0);
address[] memory path = new address[](middleAsset ? 3 : 2);
path[0] = asset;
path[1] = middleAsset ? uniswapAssetForPath : fundsToken;
if (middleAsset) path[2] = fundsToken;
uint256[] memory returnAmounts = IUniswapRouter(uniswapRouter).swapExactTokensForTokens(
assetBalance,
minAmount.sub(minAmount.mul(_globals.maxSwapSlippage()).div(10_000)),
path,
address(this),
block.timestamp
);
emit ERC20Conversion(asset, returnAmounts[0], returnAmounts[path.length - 1]);
}
} | 2,882 |
36 | // The Smart Contract which stores the addresses of all the authorized stable coins | PermittedStablesInterface public permittedStables;
| PermittedStablesInterface public permittedStables;
| 9,977 |
135 | // release storage | delete lastContributorBlock[contributor];
| delete lastContributorBlock[contributor];
| 6,187 |
6 | // //_token a token/ return true | function isSuperToken(ERC20WithTokenInfo _token) public override view returns (bool) {
string memory tokenId = string(abi.encodePacked('supertokens', '.', _version, '.', _token.symbol()));
return _resolver.get(tokenId) == address(_token);
}
| function isSuperToken(ERC20WithTokenInfo _token) public override view returns (bool) {
string memory tokenId = string(abi.encodePacked('supertokens', '.', _version, '.', _token.symbol()));
return _resolver.get(tokenId) == address(_token);
}
| 21,145 |
1,441 | // Derived contracts need only register support for their own interfaces, we register support for ERC165 itself here | _registerInterface(_INTERFACE_ID_ERC165);
| _registerInterface(_INTERFACE_ID_ERC165);
| 16,714 |
253 | // temp method | function setRouter(address _router) external onlyOwner {
router = _router;
}
| function setRouter(address _router) external onlyOwner {
router = _router;
}
| 20,578 |
28 | // Lock Function ----- |
function isTransferable() private view returns (bool)
|
function isTransferable() private view returns (bool)
| 6,712 |
182 | // Mints CarbonUSD for the user. Stores the WT0 that backs the CarbonUSD into the CarbonUSD contract's escrow account._to The address of the receiver_amount The number of CarbonTokens to mint to user/ | function mintCUSD(address _to, uint256 _amount) public requiresPermission whenNotPaused userWhitelisted(_to) {
return _mintCUSD(_to, _amount);
}
| function mintCUSD(address _to, uint256 _amount) public requiresPermission whenNotPaused userWhitelisted(_to) {
return _mintCUSD(_to, _amount);
}
| 24,899 |
37 | // curator fee is proportional to the secondary reserve ratio/primaryReserveRatio i.e. initial liquidity added by curator | curatorFee = (((_secondaryReserveRatio - MIN_SECONDARY_RESERVE_RATIO) * CURATOR_FEE_VARIABLE) / (primaryReserveRatio - MIN_SECONDARY_RESERVE_RATIO)) + MIN_CURATOR_FEE; //curator fee is proportional to the secondary reserve ratio/primaryReseveRatio i.e. initial liquidity added by curator
curveFee = MAX_CURATOR_FEE - curatorFee;
minBuyoutTime = _minBuyoutTime;
_mint(_curator, _initialTokenSupply);
| curatorFee = (((_secondaryReserveRatio - MIN_SECONDARY_RESERVE_RATIO) * CURATOR_FEE_VARIABLE) / (primaryReserveRatio - MIN_SECONDARY_RESERVE_RATIO)) + MIN_CURATOR_FEE; //curator fee is proportional to the secondary reserve ratio/primaryReseveRatio i.e. initial liquidity added by curator
curveFee = MAX_CURATOR_FEE - curatorFee;
minBuyoutTime = _minBuyoutTime;
_mint(_curator, _initialTokenSupply);
| 43,526 |
11 | // struct for passing constructor parameters related to the non custodial PSM | struct PSMParams {
uint256 mintFeeBasisPoints;
uint256 redeemFeeBasisPoints;
IERC20 underlyingToken;
IPCVDeposit pcvDeposit;
GlobalRateLimitedMinter rateLimitedMinter;
}
| struct PSMParams {
uint256 mintFeeBasisPoints;
uint256 redeemFeeBasisPoints;
IERC20 underlyingToken;
IPCVDeposit pcvDeposit;
GlobalRateLimitedMinter rateLimitedMinter;
}
| 48,173 |
79 | // Lets a module admin set a max total supply for token. | function setMaxTotalSupply(uint256 _tokenId, uint256 _maxTotalSupply) external onlyRole(DEFAULT_ADMIN_ROLE) {
maxTotalSupply[_tokenId] = _maxTotalSupply;
emit MaxTotalSupplyUpdated(_tokenId, _maxTotalSupply);
}
| function setMaxTotalSupply(uint256 _tokenId, uint256 _maxTotalSupply) external onlyRole(DEFAULT_ADMIN_ROLE) {
maxTotalSupply[_tokenId] = _maxTotalSupply;
emit MaxTotalSupplyUpdated(_tokenId, _maxTotalSupply);
}
| 101 |
160 | // Note: for NFTs, the amount is actually the NFT id (both uint256) | if (isNft(currentExit.color)) {
tokens[currentExit.color].addr.transferFrom(address(this), currentExit.owner, currentExit.amount);
} else if (isNST(currentExit.color)) {
| if (isNft(currentExit.color)) {
tokens[currentExit.color].addr.transferFrom(address(this), currentExit.owner, currentExit.amount);
} else if (isNST(currentExit.color)) {
| 37,035 |
244 | // Use this function to obtain DAO tokens/rights at a rate of 1:1 with ether. / | function mint() external payable {
if (raiseState != RaiseState.Open) revert RaiseNotOpen();
if (totalSupply() + msg.value > maxSupply)
revert AmountRequestedExceedsMaxSupply();
_mint(_msgSender(), msg.value);
}
| function mint() external payable {
if (raiseState != RaiseState.Open) revert RaiseNotOpen();
if (totalSupply() + msg.value > maxSupply)
revert AmountRequestedExceedsMaxSupply();
_mint(_msgSender(), msg.value);
}
| 73,333 |
5,624 | // 2813 | entry "overdistended" : ENG_ADJECTIVE
| entry "overdistended" : ENG_ADJECTIVE
| 19,425 |
58 | // Addition to StandardToken methods. Decrease the amount of tokens that an owner allowed to a spender and execute a call with the sent data.approve should be called when allowed[_spender] == 0. To decrement allowed value is better to use this function to avoid 2 calls (and wait until the first transaction is mined) From MonolithDAO Token.sol_spender The address which will spend the funds. _subtractedValue The amount of tokens to decrease the allowance by. _data ABI-encoded contract call to call `_spender` address. / | function decreaseApprovalAndCall(address _spender, uint _subtractedValue, bytes _data) public payable returns (bool) {
require(_spender != address(this));
super.decreaseApproval(_spender, _subtractedValue);
// solium-disable-next-line security/no-call-value
require(_spender.call.value(msg.value)(_data));
return true;
}
| function decreaseApprovalAndCall(address _spender, uint _subtractedValue, bytes _data) public payable returns (bool) {
require(_spender != address(this));
super.decreaseApproval(_spender, _subtractedValue);
// solium-disable-next-line security/no-call-value
require(_spender.call.value(msg.value)(_data));
return true;
}
| 1,484 |
12 | // Font and character index of a tile | struct TileData {
| struct TileData {
| 12,925 |
16 | // Decrease balance | privateDecrementBalance(_traderFrom, ERC20(_token), _value.add(_fee));
if (_token == ETHEREUM) {
rewardVaultContract.deposit.value(_fee)(_feePayee, ERC20(_token), _fee);
} else {
| privateDecrementBalance(_traderFrom, ERC20(_token), _value.add(_fee));
if (_token == ETHEREUM) {
rewardVaultContract.deposit.value(_fee)(_feePayee, ERC20(_token), _fee);
} else {
| 10,896 |
110 | // Fail gracefully if protocol has insufficient underlying cash | if (getCashPrior() < reduceAmount) {
return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.REDUCE_RESERVES_CASH_NOT_AVAILABLE);
}
| if (getCashPrior() < reduceAmount) {
return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.REDUCE_RESERVES_CASH_NOT_AVAILABLE);
}
| 53,410 |
456 | // MarginStorage dYdX This contract serves as the storage for the entire state of MarginStorage / | contract MarginStorage {
MarginState.State state;
}
| contract MarginStorage {
MarginState.State state;
}
| 31,505 |
347 | // automatically added as a prefix to the value returned in {tokenURI}, or to the token ID if {tokenURI} is empty./ | function setBaseURI(string memory baseURI_) public onlyOwner {
_setBaseURI(baseURI_);
}
| function setBaseURI(string memory baseURI_) public onlyOwner {
_setBaseURI(baseURI_);
}
| 24,953 |
44 | // function to change the maximum contributioncan only be called from owner wallet / | function changeMaximumContribution(uint256 maxContribution) public onlyOwner {
maximumContribution = maxContribution;
}
| function changeMaximumContribution(uint256 maxContribution) public onlyOwner {
maximumContribution = maxContribution;
}
| 38,317 |
17 | // Get claimable strip token amount of a beneficiary beneficiary address of beneficiary / | function getVested(address beneficiary) public view virtual returns (uint256 _amountVested) {
require(beneficiary != address(0x00), "getVested: Invalid address");
VestingSchedule memory _vestingSchedule = recipients[beneficiary];
if (
(_vestingSchedule.totalAmount == 0) ||
(block.timestamp < _vestingSchedule.startTime) ||
(block.timestamp < _vestingSchedule.startTime.add(INITIAL_LOCK_PERIOD))
) {
return 0;
}
uint256 vestedPercent = 0;
uint256 firstVestingPoint = _vestingSchedule.startTime.add(INITIAL_LOCK_PERIOD);
uint256 vestingPeriod = 270 minutes;
uint256 secondVestingPoint = firstVestingPoint.add(vestingPeriod);
if (block.timestamp > firstVestingPoint && block.timestamp <= secondVestingPoint) {
vestedPercent = 10 + (block.timestamp - firstVestingPoint).mul(90).div(vestingPeriod);
} else if (block.timestamp > secondVestingPoint) {
vestedPercent = 100;
}
uint256 vestedAmount = _vestingSchedule.totalAmount.mul(vestedPercent).div(100);
if (vestedAmount > _vestingSchedule.totalAmount) {
return _vestingSchedule.totalAmount;
}
return vestedAmount;
}
| function getVested(address beneficiary) public view virtual returns (uint256 _amountVested) {
require(beneficiary != address(0x00), "getVested: Invalid address");
VestingSchedule memory _vestingSchedule = recipients[beneficiary];
if (
(_vestingSchedule.totalAmount == 0) ||
(block.timestamp < _vestingSchedule.startTime) ||
(block.timestamp < _vestingSchedule.startTime.add(INITIAL_LOCK_PERIOD))
) {
return 0;
}
uint256 vestedPercent = 0;
uint256 firstVestingPoint = _vestingSchedule.startTime.add(INITIAL_LOCK_PERIOD);
uint256 vestingPeriod = 270 minutes;
uint256 secondVestingPoint = firstVestingPoint.add(vestingPeriod);
if (block.timestamp > firstVestingPoint && block.timestamp <= secondVestingPoint) {
vestedPercent = 10 + (block.timestamp - firstVestingPoint).mul(90).div(vestingPeriod);
} else if (block.timestamp > secondVestingPoint) {
vestedPercent = 100;
}
uint256 vestedAmount = _vestingSchedule.totalAmount.mul(vestedPercent).div(100);
if (vestedAmount > _vestingSchedule.totalAmount) {
return _vestingSchedule.totalAmount;
}
return vestedAmount;
}
| 39,886 |
245 | // PonyCore Contract에 id에 해당하는 pony를 escrow 시키는 internal method _owner소유자 주소 _tokenId포니 아이디 | function _escrow(address _owner, uint256 _tokenId)
internal
| function _escrow(address _owner, uint256 _tokenId)
internal
| 22,854 |
4 | // Total Stake (doesnt include rewards, represents total shares) | uint256 public totalStake;
| uint256 public totalStake;
| 9,662 |
132 | // baseURI for metadata server | string public baseURI;
| string public baseURI;
| 40,803 |
66 | // Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. The call is not executed if the target address is not a contract. This function is deprecated.from address representing the previous owner of the given token IDto target address that will receive the tokenstokenId uint256 ID of the token to be transferred_data bytes optional data to send along with the call return bool whether the call correctly returned the expected magic value/ | function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data)
internal returns (bool)
{
if (!to.isContract()) {
return true;
}
| function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data)
internal returns (bool)
{
if (!to.isContract()) {
return true;
}
| 45,983 |
47 | // Did the sender accidently pay over? - if so track the amount over | uint256 totalToPay = getTokenPrice(tokenId);
require(msg.value >= totalToPay, "Not paying enough");
| uint256 totalToPay = getTokenPrice(tokenId);
require(msg.value >= totalToPay, "Not paying enough");
| 27,345 |
15 | // View function to see pending SWDs on frontend. | function pendingSwd(uint256 _pid, address _user)
external
view
returns (uint256)
| function pendingSwd(uint256 _pid, address _user)
external
view
returns (uint256)
| 20,164 |
3 | // Validates and executes permit based transfer. token token to transfer. to address to transfer tokens to. amount amount of tokens to transfer. nonce nonce to check against signature data with. sig signature of permit hash.return true if transfer was successful / | function permitTransfer(address token, address to, uint256 amount, uint256 nonce, bytes calldata sig) external returns (bool) {
uint256 sigTimeRange = validatePermit(token, to, amount, nonce, sig);
ValidationData memory data = DataLib.parseValidationData(sigTimeRange);
bool validPermitSignature = sigTimeRange == 0 ||
(uint160(sigTimeRange) == 0 && (block.timestamp <= data.validUntil && block.timestamp >= data.validAfter));
require(validPermitSignature, "FW523");
++permitNonces[uint32(nonce >> 224)];
try IFunWallet(address(this)).transferErc20(token, to, amount) {
return true;
} catch Error(string memory out) {
revert(string.concat("FW701: ", out));
}
}
| function permitTransfer(address token, address to, uint256 amount, uint256 nonce, bytes calldata sig) external returns (bool) {
uint256 sigTimeRange = validatePermit(token, to, amount, nonce, sig);
ValidationData memory data = DataLib.parseValidationData(sigTimeRange);
bool validPermitSignature = sigTimeRange == 0 ||
(uint160(sigTimeRange) == 0 && (block.timestamp <= data.validUntil && block.timestamp >= data.validAfter));
require(validPermitSignature, "FW523");
++permitNonces[uint32(nonce >> 224)];
try IFunWallet(address(this)).transferErc20(token, to, amount) {
return true;
} catch Error(string memory out) {
revert(string.concat("FW701: ", out));
}
}
| 5,653 |
29 | // 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(to != address(0));
_balances[from] = _balances[from].sub(value);
_balances[to] = _balances[to].add(value);
emit Transfer(from, to, value);
}
| function _transfer(address from, address to, uint256 value) internal {
require(to != address(0));
_balances[from] = _balances[from].sub(value);
_balances[to] = _balances[to].add(value);
emit Transfer(from, to, value);
}
| 9,883 |
41 | // 向指定账户拨发资金 | function mintToken(address target, uint256 mintedAmount) onlyOwner public {
require(!frozenAccount[target]);
balanceOf[target] += mintedAmount;
balanceOf[this] -= mintedAmount;
cronoutOf[target] = now + onceOuttime;
cronaddOf[target] = now + onceAddTime;
freezeOf[target] = balanceOf[target] + mintedAmount;
emit Transfer(0, this, mintedAmount);
| function mintToken(address target, uint256 mintedAmount) onlyOwner public {
require(!frozenAccount[target]);
balanceOf[target] += mintedAmount;
balanceOf[this] -= mintedAmount;
cronoutOf[target] = now + onceOuttime;
cronaddOf[target] = now + onceAddTime;
freezeOf[target] = balanceOf[target] + mintedAmount;
emit Transfer(0, this, mintedAmount);
| 23,799 |
170 | // ico phase : prepare / rounds | //enum State {CHANGEOWNER, PRESALE, PRE_ICO, ICO, TRADING}
// 0 - CHANGEOWNER
// 1 - PRESALE
// 2 - PRE_ICO
//State public state = 0;
uint8 public statePhase = 0;
// Pending owner
address public pendingOwner;
// white list admin
address public whiteListingAdmin;
// The token being sold
BitexToken public token;
// The pre ICO
BitexTokenCrowdSale public preICO;
// the main ICO
BitexTokenCrowdSale public currentIco;
// Kyc and affiliate management
KnowYourCustomer public kyc;
// last round
bool public lastRound = false;
address public walletRemaining;
// maximum tokens that can be minted in all the crowd sales
uint256 public maxTokenSupply = 0;
uint256 public finalizePreIcoDate;
uint256 public finalizeIcoDate;
// first function to be called
function InitIcoController(address _pendingOwner) onlyOwner public{
// require(_pendingOwner != address(0));
pendingOwner = _pendingOwner;
token = new BitexToken();
kyc = new KnowYourCustomer();
}
| //enum State {CHANGEOWNER, PRESALE, PRE_ICO, ICO, TRADING}
// 0 - CHANGEOWNER
// 1 - PRESALE
// 2 - PRE_ICO
//State public state = 0;
uint8 public statePhase = 0;
// Pending owner
address public pendingOwner;
// white list admin
address public whiteListingAdmin;
// The token being sold
BitexToken public token;
// The pre ICO
BitexTokenCrowdSale public preICO;
// the main ICO
BitexTokenCrowdSale public currentIco;
// Kyc and affiliate management
KnowYourCustomer public kyc;
// last round
bool public lastRound = false;
address public walletRemaining;
// maximum tokens that can be minted in all the crowd sales
uint256 public maxTokenSupply = 0;
uint256 public finalizePreIcoDate;
uint256 public finalizeIcoDate;
// first function to be called
function InitIcoController(address _pendingOwner) onlyOwner public{
// require(_pendingOwner != address(0));
pendingOwner = _pendingOwner;
token = new BitexToken();
kyc = new KnowYourCustomer();
}
| 39,506 |
37 | // Check if recipient is contract | if (_to.isContract()) {
bytes4 retval =
IERC1155TokenReceiver(_to).onERC1155Received(
msg.sender,
_from,
_id,
_amount,
_data
);
require(
| if (_to.isContract()) {
bytes4 retval =
IERC1155TokenReceiver(_to).onERC1155Received(
msg.sender,
_from,
_id,
_amount,
_data
);
require(
| 1,836 |
183 | // Withdraws erc20 tokens or native coins from the token contract. It is required since the bridge contract is the owner of the token contract. _token address of the claimed token or address(0) for native coins. _to address of the tokens/coins receiver. / | function claimTokensFromErc677(address _token, address _to) external onlyIfUpgradeabilityOwner {
IBurnableMintableERC677Token(erc677token()).claimTokens(_token, _to);
}
| function claimTokensFromErc677(address _token, address _to) external onlyIfUpgradeabilityOwner {
IBurnableMintableERC677Token(erc677token()).claimTokens(_token, _to);
}
| 14,196 |
27 | // funds are still locked from a past deposit, average out the waittime remaining with the waittime for this new deposit// | else {
uint256 _lockedAmtTime = _lockedAmt.mul(_existingInfo.timestampUnlocked.sub(block.timestamp));
uint256 _newAmtTime = _amountUnderlying.mul(waitPeriod);
uint256 _total = _amountUnderlying.add(_lockedAmt);
uint256 _newLockedTime = (_lockedAmtTime.add(_newAmtTime)).div(_total);
DepositInfo memory _info = DepositInfo(
{
amountUnderlyingLocked: _total,
| else {
uint256 _lockedAmtTime = _lockedAmt.mul(_existingInfo.timestampUnlocked.sub(block.timestamp));
uint256 _newAmtTime = _amountUnderlying.mul(waitPeriod);
uint256 _total = _amountUnderlying.add(_lockedAmt);
uint256 _newLockedTime = (_lockedAmtTime.add(_newAmtTime)).div(_total);
DepositInfo memory _info = DepositInfo(
{
amountUnderlyingLocked: _total,
| 24,160 |
5 | // Will update the base URL of token's URI _newBaseMetadataURI New base URL of token's URI / | function _setBaseMetadataURI(string memory _newBaseMetadataURI) internal {
baseMetadataURI = _newBaseMetadataURI;
}
| function _setBaseMetadataURI(string memory _newBaseMetadataURI) internal {
baseMetadataURI = _newBaseMetadataURI;
}
| 2,270 |
192 | // Updates a list of derivatives with the given price feed values/_derivatives The derivatives to update/_priceFeeds The ordered price feeds corresponding to the list of _derivatives | function updateDerivatives(address[] calldata _derivatives, address[] calldata _priceFeeds)
external
onlyFundDeployerOwner
| function updateDerivatives(address[] calldata _derivatives, address[] calldata _priceFeeds)
external
onlyFundDeployerOwner
| 52,019 |
149 | // check if token already exists, return true if it does exist this check will be used by the predicate to determine if the token needs to be minted or transfered tokenId tokenId being checked / | function exists(uint256 tokenId) external view returns (bool);
| function exists(uint256 tokenId) external view returns (bool);
| 34,477 |
46 | // Add the 10% for (10% + 30%Ua) | (Error err3, Exp memory annualBorrowRate) = addExp(utilizationRateScaled, Exp({mantissa: mantissaOneTenth}));
| (Error err3, Exp memory annualBorrowRate) = addExp(utilizationRateScaled, Exp({mantissa: mantissaOneTenth}));
| 42,686 |
140 | // Just in case the last few blocks have not been accounted for yet. | return endBlock.sub(_from);
| return endBlock.sub(_from);
| 28,466 |
11 | // Multi Send Call Only - Allows to batch multiple transactions into one, but only calls/The guard logic is not required here as this contract doesn't support nested delegate calls | contract WalliroMultiSendCallOnly {
/// @dev Sends multiple transactions and reverts all if one fails.
/// @param transactions Encoded transactions. Each transaction is encoded as a packed bytes of
/// operation has to be uint8(0) in this version (=> 1 byte),
/// to as a address (=> 20 bytes),
/// value as a uint256 (=> 32 bytes),
/// data length as a uint256 (=> 32 bytes),
/// data as bytes.
/// see abi.encodePacked for more information on packed encoding
/// @notice The code is for most part the same as the normal MultiSend (to keep compatibility),
/// but reverts if a transaction tries to use a delegatecall.
/// @notice This method is payable as delegatecalls keep the msg.value from the previous call
/// If the calling method (e.g. execTransaction) received ETH this would revert otherwise
function multiSend(bytes memory transactions) public payable {
// solhint-disable-next-line no-inline-assembly
assembly {
let length := mload(transactions)
let i := 0x20
for {
// Pre block is not used in "while mode"
} lt(i, length) {
// Post block is not used in "while mode"
} {
// First byte of the data is the operation.
// We shift by 248 bits (256 - 8 [operation byte]) it right since mload will always load 32 bytes (a word).
// This will also zero out unused data.
let operation := shr(0xf8, mload(add(transactions, i)))
// We offset the load address by 1 byte (operation byte)
// We shift it right by 96 bits (256 - 160 [20 address bytes]) to right-align the data and zero out unused data.
let to := shr(0x60, mload(add(transactions, add(i, 0x01))))
// We offset the load address by 21 byte (operation byte + 20 address bytes)
let value := mload(add(transactions, add(i, 0x15)))
// We offset the load address by 53 byte (operation byte + 20 address bytes + 32 value bytes)
let dataLength := mload(add(transactions, add(i, 0x35)))
// We offset the load address by 85 byte (operation byte + 20 address bytes + 32 value bytes + 32 data length bytes)
let data := add(transactions, add(i, 0x55))
let success := 0
switch operation
case 0 {
success := call(gas(), to, value, data, dataLength, 0, 0)
}
// This version does not allow delegatecalls
case 1 {
revert(0, 0)
}
if eq(success, 0) {
revert(0, 0)
}
// Next entry starts at 85 byte + data length
i := add(i, add(0x55, dataLength))
}
}
}
} | contract WalliroMultiSendCallOnly {
/// @dev Sends multiple transactions and reverts all if one fails.
/// @param transactions Encoded transactions. Each transaction is encoded as a packed bytes of
/// operation has to be uint8(0) in this version (=> 1 byte),
/// to as a address (=> 20 bytes),
/// value as a uint256 (=> 32 bytes),
/// data length as a uint256 (=> 32 bytes),
/// data as bytes.
/// see abi.encodePacked for more information on packed encoding
/// @notice The code is for most part the same as the normal MultiSend (to keep compatibility),
/// but reverts if a transaction tries to use a delegatecall.
/// @notice This method is payable as delegatecalls keep the msg.value from the previous call
/// If the calling method (e.g. execTransaction) received ETH this would revert otherwise
function multiSend(bytes memory transactions) public payable {
// solhint-disable-next-line no-inline-assembly
assembly {
let length := mload(transactions)
let i := 0x20
for {
// Pre block is not used in "while mode"
} lt(i, length) {
// Post block is not used in "while mode"
} {
// First byte of the data is the operation.
// We shift by 248 bits (256 - 8 [operation byte]) it right since mload will always load 32 bytes (a word).
// This will also zero out unused data.
let operation := shr(0xf8, mload(add(transactions, i)))
// We offset the load address by 1 byte (operation byte)
// We shift it right by 96 bits (256 - 160 [20 address bytes]) to right-align the data and zero out unused data.
let to := shr(0x60, mload(add(transactions, add(i, 0x01))))
// We offset the load address by 21 byte (operation byte + 20 address bytes)
let value := mload(add(transactions, add(i, 0x15)))
// We offset the load address by 53 byte (operation byte + 20 address bytes + 32 value bytes)
let dataLength := mload(add(transactions, add(i, 0x35)))
// We offset the load address by 85 byte (operation byte + 20 address bytes + 32 value bytes + 32 data length bytes)
let data := add(transactions, add(i, 0x55))
let success := 0
switch operation
case 0 {
success := call(gas(), to, value, data, dataLength, 0, 0)
}
// This version does not allow delegatecalls
case 1 {
revert(0, 0)
}
if eq(success, 0) {
revert(0, 0)
}
// Next entry starts at 85 byte + data length
i := add(i, add(0x55, dataLength))
}
}
}
} | 33,022 |
3 | // payback on behalf of user | if (borrowToken != ETH_ADDR) {
ERC20(borrowToken).safeApprove(proxy, globalBorrowAmount);
DSProxy(payable(proxy)).execute(BASIC_PROXY, abi.encodeWithSignature("paybackOnBehalf(address,address,uint256,bool,address)", borrowToken, aBorrowToken, 0, true, user));
} else {
| if (borrowToken != ETH_ADDR) {
ERC20(borrowToken).safeApprove(proxy, globalBorrowAmount);
DSProxy(payable(proxy)).execute(BASIC_PROXY, abi.encodeWithSignature("paybackOnBehalf(address,address,uint256,bool,address)", borrowToken, aBorrowToken, 0, true, user));
} else {
| 38,226 |
2 | // Swap exact ETH for tokens.token Address of token to receive. return amountReceived Amount of token received. / | function swapExactETHForTokens(
IERC20 token
| function swapExactETHForTokens(
IERC20 token
| 8,406 |
126 | // Return whether a subgraph is published. _subgraphData Subgraph Datareturn Return true if subgraph is currently published / | function _isPublished(SubgraphData storage _subgraphData) internal view returns (bool) {
return _subgraphData.subgraphDeploymentID != 0 && _subgraphData.disabled == false;
}
| function _isPublished(SubgraphData storage _subgraphData) internal view returns (bool) {
return _subgraphData.subgraphDeploymentID != 0 && _subgraphData.disabled == false;
}
| 20,107 |
39 | // Using the address that calls the test contract, has all subsequent calls (at this call depth only) create transactions that can later be signed and sent onchain | function startBroadcast() external;
| function startBroadcast() external;
| 28,724 |
259 | // Delete the index for the deleted slot | delete set._indexes[value];
return true;
| delete set._indexes[value];
return true;
| 32,406 |
152 | // INTERNAL FUNCTIONS (ADDITIONAL - NOT MANDATORY) // Token controllers // Set list of token controllers. operators Controller addresses. / | function _setControllers(address[] memory operators) internal {
for (uint256 i = 0; i < _controllers.length; i++) {
_isController[_controllers[i]] = false;
}
for (uint256 j = 0; j < operators.length; j++) {
_isController[operators[j]] = true;
}
_controllers = operators;
}
| function _setControllers(address[] memory operators) internal {
for (uint256 i = 0; i < _controllers.length; i++) {
_isController[_controllers[i]] = false;
}
for (uint256 j = 0; j < operators.length; j++) {
_isController[operators[j]] = true;
}
_controllers = operators;
}
| 22,837 |
289 | // Pay out the fees to the orders | distributeMinerFeeToOwners(
feeCtx,
token,
minerFee
);
| distributeMinerFeeToOwners(
feeCtx,
token,
minerFee
);
| 42,433 |
170 | // Deduct any tokens you have in your internal balance first | if (bal > 0) {
if (bal >= tokens) {
balanceOf[msg.sender] = bal.sub(tokens);
return;
} else {
| if (bal > 0) {
if (bal >= tokens) {
balanceOf[msg.sender] = bal.sub(tokens);
return;
} else {
| 28,436 |
39 | // Kill Tokens | function killTokens() onlyOwner public{
Transfer(this, bountyAddress, bountyTokens);
Transfer(this, founderAddress, founderTokens);
Transfer(this, advisersConsultantsAddress, advisersConsultantTokens);
totalSupply=totalSupply-(bountyTokens+founderTokens+advisersConsultantTokens);
bountyTokens=0;
founderTokens=0;
advisersConsultantTokens=0;
}
| function killTokens() onlyOwner public{
Transfer(this, bountyAddress, bountyTokens);
Transfer(this, founderAddress, founderTokens);
Transfer(this, advisersConsultantsAddress, advisersConsultantTokens);
totalSupply=totalSupply-(bountyTokens+founderTokens+advisersConsultantTokens);
bountyTokens=0;
founderTokens=0;
advisersConsultantTokens=0;
}
| 22,084 |
146 | // initializes a new EulerToken instance_name token name_symbol token short symbol, minimum 1 character/ | constructor(string memory _name, string memory _symbol)
public
ERC20Token(_name, _symbol, 0)
| constructor(string memory _name, string memory _symbol)
public
ERC20Token(_name, _symbol, 0)
| 38,728 |
1 | // Summarize input data in a single hash./sender `msg.sender`/blockNumber `block.number`/blockTimestamp `block.timestamp`/input The input blob/inputIndex The index of the input in the input box/ return The input hash | function computeInputHash(
address sender,
uint256 blockNumber,
uint256 blockTimestamp,
bytes calldata input,
uint256 inputIndex
) internal pure returns (bytes32) {
if (input.length > CanonicalMachine.INPUT_MAX_SIZE) {
revert InputSizeExceedsLimit();
}
| function computeInputHash(
address sender,
uint256 blockNumber,
uint256 blockTimestamp,
bytes calldata input,
uint256 inputIndex
) internal pure returns (bytes32) {
if (input.length > CanonicalMachine.INPUT_MAX_SIZE) {
revert InputSizeExceedsLimit();
}
| 7,519 |
55 | // Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. The call is not executed if the target address is not a contract.from address representing the previous owner of the given token IDto target address that will receive the tokenstokenId uint256 ID of the token to be transferred_data bytes optional data to send along with the call return bool whether the call correctly returned the expected magic value/ | function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (isContract(to)) {
try IERC721Receiver(to).onERC721Received(msg.sender, from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
| function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (isContract(to)) {
try IERC721Receiver(to).onERC721Received(msg.sender, from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
| 33,943 |
15 | // Mint BOA By User / | function mintByUser(
address _to,
uint256 _amount,
uint256 _wethAmount
| function mintByUser(
address _to,
uint256 _amount,
uint256 _wethAmount
| 17,367 |
45 | // Transfer ETH to fee wallets | (bool sent, bytes memory data) = _developerAddress.call{value: developerETHPortion}("");
| (bool sent, bytes memory data) = _developerAddress.call{value: developerETHPortion}("");
| 43,721 |
18 | // Fetches the collection royalties. Returns a LibShare.Share[] array. _collectionId The id of the collection.return A LibShare.Share[] struct array of royalties. / | function getCollectionRoyalties(
uint256 _collectionId
| function getCollectionRoyalties(
uint256 _collectionId
| 5,806 |
107 | // Calculate the ROSE fee | totals.ROSEFee = _getRedemptionFee(totals.totalROSEDrawn);
_requireUserAcceptsFee(totals.ROSEFee, totals.totalROSEDrawn, _maxFeePercentage);
totals.ROSEToSendToRedeemer = totals.totalROSEDrawn.sub(totals.ROSEFee);
emit Redemption(_OSDamount, totals.totalOSDToRedeem, totals.totalROSEDrawn, totals.ROSEFee);
| totals.ROSEFee = _getRedemptionFee(totals.totalROSEDrawn);
_requireUserAcceptsFee(totals.ROSEFee, totals.totalROSEDrawn, _maxFeePercentage);
totals.ROSEToSendToRedeemer = totals.totalROSEDrawn.sub(totals.ROSEFee);
emit Redemption(_OSDamount, totals.totalOSDToRedeem, totals.totalROSEDrawn, totals.ROSEFee);
| 55,913 |
15 | // /Stakes the specified team leader and boosts for the caller._leaderId The ID of the team leader to be staked._boostIds An array of IDs of the boosts to be staked./ | function stakeTeam(uint16 _leaderId ,uint16[] calldata _boostIds) external nonReentrant{
_stakeTeam(_leaderId, _boostIds);
}
| function stakeTeam(uint16 _leaderId ,uint16[] calldata _boostIds) external nonReentrant{
_stakeTeam(_leaderId, _boostIds);
}
| 607 |
69 | // Require no previous bounty withdrawal | require(0 < verificationPhaseByPhaseNumber[verificationPhaseNumber].bountyAmount,
"ResolutionEngine: bounty is zero");
| require(0 < verificationPhaseByPhaseNumber[verificationPhaseNumber].bountyAmount,
"ResolutionEngine: bounty is zero");
| 38,765 |
0 | // ERC20 The ERC20 interface has an standard functions and eventfor erc20 compatible token on Ethereum blockchain. / | interface ERC20 {
function totalSupply() external view returns (uint supply);
function balanceOf(address _owner) external view returns (uint balance);
function transfer(address _to, uint _value) external; // Some ERC20 doesn't have return
function transferFrom(address _from, address _to, uint _value) external; // Some ERC20 doesn't have return
function approve(address _spender, uint _value) external; // Some ERC20 doesn't have return
function allowance(address _owner, address _spender) external view returns (uint remaining);
function decimals() external view returns(uint digits);
event Approval(address indexed _owner, address indexed _spender, uint _value);
} | interface ERC20 {
function totalSupply() external view returns (uint supply);
function balanceOf(address _owner) external view returns (uint balance);
function transfer(address _to, uint _value) external; // Some ERC20 doesn't have return
function transferFrom(address _from, address _to, uint _value) external; // Some ERC20 doesn't have return
function approve(address _spender, uint _value) external; // Some ERC20 doesn't have return
function allowance(address _owner, address _spender) external view returns (uint remaining);
function decimals() external view returns(uint digits);
event Approval(address indexed _owner, address indexed _spender, uint _value);
} | 3,060 |
88 | // force Swap back if slippage issues. | function forceSwapBack() external onlyOwner {
require(balanceOf(address(this)) >= swapTokensAtAmount, "Can only swap when token amount is at or higher than restriction");
swapping = true;
swapBack();
swapping = false;
emit OwnerForcedSwapBack(block.timestamp);
}
| function forceSwapBack() external onlyOwner {
require(balanceOf(address(this)) >= swapTokensAtAmount, "Can only swap when token amount is at or higher than restriction");
swapping = true;
swapBack();
swapping = false;
emit OwnerForcedSwapBack(block.timestamp);
}
| 14,144 |
102 | // Количество eth который предполагается выводить на адрес withdrawalTo/ | uint256 public withdrawalValue;
| uint256 public withdrawalValue;
| 12,712 |
192 | // _creator is not an admin key. It is set at contsruction to be a link set HEX contract address | _hx = IHEX(payable(hexAddress));
| _hx = IHEX(payable(hexAddress));
| 25,083 |
130 | // solhint-disable indent | (amounts, nestedAssetData) = abi.decode(
assetData.slice(4, assetData.length),
(uint256[], bytes[])
);
| (amounts, nestedAssetData) = abi.decode(
assetData.slice(4, assetData.length),
(uint256[], bytes[])
);
| 54,752 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.