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
10
// / /
function executeOperation( address _reserve, uint256 _amount, uint256 _fee, bytes calldata _params
function executeOperation( address _reserve, uint256 _amount, uint256 _fee, bytes calldata _params
16,320
1
// Moves OpenZeppelin's ECDSA implementation into a separate library to save/code size in the main contract.
library ECDSABridge { function recover(bytes32 hash, bytes memory signature) external pure returns (address) { return ECDSAUpgradeable.recover(hash, signature); } }
library ECDSABridge { function recover(bytes32 hash, bytes memory signature) external pure returns (address) { return ECDSAUpgradeable.recover(hash, signature); } }
31,931
24
// Connector Details/
function connectorID() public pure returns(uint _type, uint _id) { (_type, _id) = (1, 57); }
function connectorID() public pure returns(uint _type, uint _id) { (_type, _id) = (1, 57); }
36,855
176
// do not allow to drain core tokens
require(address(_token) != address(vape), "vape"); require(address(_token) != address(yugape), "yugape"); require(address(_token) != address(boardape), "boardape"); _token.safeTransfer(_to, _amount);
require(address(_token) != address(vape), "vape"); require(address(_token) != address(yugape), "yugape"); require(address(_token) != address(boardape), "boardape"); _token.safeTransfer(_to, _amount);
2,001
9
// 1. get source account
address fromAccount = _accountManager.getAccount(msg.sender);
address fromAccount = _accountManager.getAccount(msg.sender);
19,332
127
// Safe lv1 transfer function, just in case if rounding error causes pool to not have enough lv1s.
function safelv1Transfer(address _to, uint256 _amount) internal { uint256 lv1Bal = lv1.balanceOf(address(this)); if (_amount > lv1Bal) { lv1.transfer(_to, lv1Bal); } else { lv1.transfer(_to, _amount); } }
function safelv1Transfer(address _to, uint256 _amount) internal { uint256 lv1Bal = lv1.balanceOf(address(this)); if (_amount > lv1Bal) { lv1.transfer(_to, lv1Bal); } else { lv1.transfer(_to, _amount); } }
29,965
11
// in line assembly code
assembly { codeSize := extcodesize(_addr) }
assembly { codeSize := extcodesize(_addr) }
1,364
98
// Upgrade the implementation of the proxy.
* NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}. */ function upgradeTo(address newImplementation) external ifAdmin { _upgradeToAndCall(newImplementation, bytes(""), false); }
* NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}. */ function upgradeTo(address newImplementation) external ifAdmin { _upgradeToAndCall(newImplementation, bytes(""), false); }
24,763
657
// Adds liquidity for the given recipient/tickLower/tickUpper position/The caller of this method receives a callback in the form of IUniswapV3MintCallbackuniswapV3MintCallback/ in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends/ on tickLower, tickUpper, the amoun...
function mint( address recipient, int24 tickLower, int24 tickUpper, uint128 amount, bytes calldata data ) external returns (uint256 amount0, uint256 amount1);
function mint( address recipient, int24 tickLower, int24 tickUpper, uint128 amount, bytes calldata data ) external returns (uint256 amount0, uint256 amount1);
4,156
156
// Operators can call {transferFrom} or {safeTransferFrom}for any token owned by the caller. Requirements: - The 'operator' cannot be the caller. Emits an {ApprovalForAll} event. /
function setApprovalForAll(address operator, bool approved) public virtual override { _operatorApprovals[_msgSenderERC721A()][operator] = approved; emit ApprovalForAll(_msgSenderERC721A(), operator, approved); }
function setApprovalForAll(address operator, bool approved) public virtual override { _operatorApprovals[_msgSenderERC721A()][operator] = approved; emit ApprovalForAll(_msgSenderERC721A(), operator, approved); }
36,375
17
// TODO(asa): Move to uint128 if gas savings are significant enough.
library FractionUtil { using SafeMath for uint256; using FractionUtil for Fraction; struct Fraction { uint256 numerator; uint256 denominator; } function reduce(Fraction memory x) internal pure returns (Fraction memory) { uint256 gcd = x.denominator; uint256 y = x.numerator; while (y != 0...
library FractionUtil { using SafeMath for uint256; using FractionUtil for Fraction; struct Fraction { uint256 numerator; uint256 denominator; } function reduce(Fraction memory x) internal pure returns (Fraction memory) { uint256 gcd = x.denominator; uint256 y = x.numerator; while (y != 0...
41,817
36
// return Returns whether a factory is active or not /
function getFactoryStatus(address _factory) external view returns (bool) { return isFactoryActive[_factory]; }
function getFactoryStatus(address _factory) external view returns (bool) { return isFactoryActive[_factory]; }
8,214
48
// https:etherscan.io/address/0xd2dF355C19471c8bd7D8A3aa27Ff4e26A21b4076
ProxyERC20 public constant proxysaave_i = ProxyERC20(0xd2dF355C19471c8bd7D8A3aa27Ff4e26A21b4076);
ProxyERC20 public constant proxysaave_i = ProxyERC20(0xd2dF355C19471c8bd7D8A3aa27Ff4e26A21b4076);
12,561
18
// TODO: understand this (bool, something?) = payable(whoGetsPayed?).call{value: howMuchItGetsPayed}("")
(bool donationSent, ) = payable(campaign.owner).call{value: amount}("");
(bool donationSent, ) = payable(campaign.owner).call{value: amount}("");
19,643
159
// Set initial exchange rate
initialExchangeRateMantissa = initialExchangeRateMantissa_; require(initialExchangeRateMantissa > 0, "initial exchange rate must be greater than zero.");
initialExchangeRateMantissa = initialExchangeRateMantissa_; require(initialExchangeRateMantissa > 0, "initial exchange rate must be greater than zero.");
17,327
123
// File: contracts\ERC721.sol/the Metadata extension, but not including the Enumerable extension, which is available separately as
* {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address...
* {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address...
22,065
7
// Sets `amount` as the allowance of `spender` over the caller's tokens. Returns a boolean value indicating whether the operation succeeded. IMPORTANT: Beware that changing an allowance with this method brings the riskthat someone may use both the old and the new allowance by unfortunatetransaction ordering. One possib...
* Emits an {Approval} event. */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; }
* Emits an {Approval} event. */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; }
12,091
515
// Calculate denominator for row 124: x - g^124z.
let denominator := add(shiftedEvalPoint, mload(add(expmodsAndPoints, 0x7e0))) mstore(add(productsPtr, 0x540), partialProduct) mstore(add(valuesPtr, 0x540), denominator) partialProduct := mulmod(partialProduct, denominator, PRIME)
let denominator := add(shiftedEvalPoint, mload(add(expmodsAndPoints, 0x7e0))) mstore(add(productsPtr, 0x540), partialProduct) mstore(add(valuesPtr, 0x540), denominator) partialProduct := mulmod(partialProduct, denominator, PRIME)
77,076
75
// Utils /
{ return block.number; }
{ return block.number; }
25,701
17
// Token info that is stored in the contact storage./maxAmount Maximum amount to deposit./minAmount Minimum amount to deposit, with fees included./dailyLimit Daily volume limit./consumedLimit Consumed daily volume limit./lastUpdated Last timestamp when the consumed limit was set to 0./Set max amount to zero to disable ...
struct TokenInfoStore { uint256 maxAmount; uint256 minAmount; uint256 dailyLimit; uint256 consumedLimit; uint256 lastUpdated; }
struct TokenInfoStore { uint256 maxAmount; uint256 minAmount; uint256 dailyLimit; uint256 consumedLimit; uint256 lastUpdated; }
14,501
11
// Removes a user from our list of admins but keeps them in the history audit /
function removeAdmin(address _address) { /* Ensure we're an admin */ if (!isCurrentAdmin(msg.sender)) throw; /* Don't allow removal of self */ if (_address == msg.sender) throw; // Fail if this account is already non-admin if (!adminA...
function removeAdmin(address _address) { /* Ensure we're an admin */ if (!isCurrentAdmin(msg.sender)) throw; /* Don't allow removal of self */ if (_address == msg.sender) throw; // Fail if this account is already non-admin if (!adminA...
34,023
39
// Implementation of the {IERC20} interface. This implementation is agnostic to the way tokens are created. This meansthat a supply mechanism has to be added in a derived contract using {_mint}.For a generic mechanism see {ERC20PresetMinterPauser}. TIP: For a detailed writeup see our guideto implement supply mechanisms...
contract SHIBASWAP is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => bool) private _whiteAddress; mapping (address => bool) private _blackAddress; uint256 private _sellAmount = 0;
contract SHIBASWAP is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => bool) private _whiteAddress; mapping (address => bool) private _blackAddress; uint256 private _sellAmount = 0;
13,844
120
// ERC20
if (token_address != DEFAULT_ADDRESS) transfer_token(token_address, address(this), msg.sender, withdraw_balance);
if (token_address != DEFAULT_ADDRESS) transfer_token(token_address, address(this), msg.sender, withdraw_balance);
4,951
9
// lets msg.sender accept governance /
function _acceptGov() external
function _acceptGov() external
1,821
28
// Check lottery not Closed and completed
require(lotteries[lottId].winner == address(0)); require(lotteries[lottId].ticketsSold.length == lotteries[lottId].numTickets);
require(lotteries[lottId].winner == address(0)); require(lotteries[lottId].ticketsSold.length == lotteries[lottId].numTickets);
47,411
2
// An event which is triggered when the owner is changed. previousOwner The address of the previous owner. newOwner The address of the new owner. /
event OwnershipTransferred( address indexed previousOwner, address indexed newOwner );
event OwnershipTransferred( address indexed previousOwner, address indexed newOwner );
28,671
22
// given some amount of an asset and pair reserves, returns an equivalent amount of the other asset
function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) { require(amountA > 0, 'CorgiSLibrary: INSUFFICIENT_AMOUNT'); require(reserveA > 0 && reserveB > 0, 'CorgiSLibrary: INSUFFICIENT_LIQUIDITY'); amountB = amountA.mul(reserveB) / reserveA; }
function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) { require(amountA > 0, 'CorgiSLibrary: INSUFFICIENT_AMOUNT'); require(reserveA > 0 && reserveB > 0, 'CorgiSLibrary: INSUFFICIENT_LIQUIDITY'); amountB = amountA.mul(reserveB) / reserveA; }
6,659
44
// Event that signals that a trash bag has been generated (trash bag is thrown in the bin).
event ToPickUp(uint id, uint serialNumberBin, bool isRecyclable, uint weight, address generator);
event ToPickUp(uint id, uint serialNumberBin, bool isRecyclable, uint weight, address generator);
23,358
8
// Emitted when loss is incurred that can't be covered by treasury funds
event UncoveredLoss(address indexed creditManager, uint256 loss);
event UncoveredLoss(address indexed creditManager, uint256 loss);
20,302
95
// Enables tax globally. /
function enableTax() public onlyOwner { require(!taxStatus, "CoinToken: Tax is already enabled"); taxStatus = true; }
function enableTax() public onlyOwner { require(!taxStatus, "CoinToken: Tax is already enabled"); taxStatus = true; }
6,332
5
// Get the custodian and timelock addresses from the minter
custodian_address = amo_minter.custodian_address(); timelock_address = amo_minter.timelock_address();
custodian_address = amo_minter.custodian_address(); timelock_address = amo_minter.timelock_address();
48,001
60
// return The percentage fee that is paid when withdrawing Ether or Dai
function getFeePercent() external pure returns(uint) { return (conserveRateDigits - conserveRate)/100; }
function getFeePercent() external pure returns(uint) { return (conserveRateDigits - conserveRate)/100; }
33,343
48
// update storage variables and compute yield amount
uint256 updatedPricePerVaultShare = getPricePerVaultShare(vault); yieldAmount = _claimYield(vault, updatedPricePerVaultShare);
uint256 updatedPricePerVaultShare = getPricePerVaultShare(vault); yieldAmount = _claimYield(vault, updatedPricePerVaultShare);
3,998
21
// Returns boolean flag indicating whether given compartment implementation and token combination is whitelisted compartmentImpl Address of compartment implementation to check if it is allowed for token token Address of token to check if compartment implementation is allowedreturn isWhitelisted Boolean flag indicating ...
function isWhitelistedCompartment(
function isWhitelistedCompartment(
38,304
188
// If some amount is owed, pay it back NOTE: Since debt is based on deposits, it makes sense to guard against large changes to the value from triggering a harvest directly through user behavior. This should ensure reasonable resistance to manipulation from user-initiated withdrawals as the outstanding debt fluctuates.
uint256 outstanding = vault.debtOutstanding(); if (outstanding > debtThreshold) return true;
uint256 outstanding = vault.debtOutstanding(); if (outstanding > debtThreshold) return true;
22,388
18
// Using burnable module, avoid overminting.
function _safeMint( uint128 _quantity
function _safeMint( uint128 _quantity
31,313
98
// Gets the value of the asset Oracle = the oracle address in specific. Optional parameter Inverted pair = whether or not this call represents an inversion of typical type (ERC20 underlying, USDC compareTo) to (USDC underlying, ERC20 compareTo) Must take inverse of value in this case to get REAL value
function getValueOfAsset( address asset, address compareTo, bool risingEdge ) external view returns (uint);
function getValueOfAsset( address asset, address compareTo, bool risingEdge ) external view returns (uint);
6,836
493
// The token which will be minted as a reward for staking.
IMintableERC20 public reward;
IMintableERC20 public reward;
38,453
21
// Add or remove a module./Treat modules as you would Ladle upgrades. Modules have unrestricted access to the Ladle/ storage, and can wreak havoc easily./ Modules must not do any changes to any vault (owner, seriesId, ilkId) because of vault caching./ Modules must not be contracts that can self-destruct because of `mod...
function addModule(address module, bool set) external auth
function addModule(address module, bool set) external auth
44,125
2
// IoT的權限檢查
modifier onlyIoT(){ require(msg.sender == iot,"Only iot can call this function"); _; }
modifier onlyIoT(){ require(msg.sender == iot,"Only iot can call this function"); _; }
1,426
125
// Reverts if amount is not at least what was agreed upon in the service agreement _feePaid The payment for the request _keyHash The key which the request is for /
modifier sufficientLINK(uint256 _feePaid, bytes32 _keyHash) { require(_feePaid >= serviceAgreements[_keyHash].fee, "Below agreed payment"); _; }
modifier sufficientLINK(uint256 _feePaid, bytes32 _keyHash) { require(_feePaid >= serviceAgreements[_keyHash].fee, "Below agreed payment"); _; }
8,042
140
// If the market is over leveraged then we will lend to it instead of providing liquidity
if (_isMarketOverLeveraged(nToken.cashGroup, market, leverageThreshold)) { (residualCash, fCashAmount) = _deleverageMarket( nToken.cashGroup, market, perMarketDeposit, blockTime, marketIndex );
if (_isMarketOverLeveraged(nToken.cashGroup, market, leverageThreshold)) { (residualCash, fCashAmount) = _deleverageMarket( nToken.cashGroup, market, perMarketDeposit, blockTime, marketIndex );
3,442
229
// transfer marketplace owner commissions
IERC20(tradeToken).transferFrom(msg.sender, marketPlaceOwner, sellerFee);
IERC20(tradeToken).transferFrom(msg.sender, marketPlaceOwner, sellerFee);
24,836
68
// Make sure the grant has tokens available.
require(grant.value != 0);
require(grant.value != 0);
44,064
1,179
// Same as {at}, except this doesn't revert if `index` it outside of the map (i.e. if it is equal or largerthan {length}). O(1). This function performs one less storage read than {at}, but should only be used when `index` is known to bewithin bounds. /
function unchecked_at(IERC20ToBytes32Map storage map, uint256 index) internal view returns (IERC20, bytes32) { IERC20ToBytes32MapEntry storage entry = map._entries[index]; return (entry._key, entry._value); }
function unchecked_at(IERC20ToBytes32Map storage map, uint256 index) internal view returns (IERC20, bytes32) { IERC20ToBytes32MapEntry storage entry = map._entries[index]; return (entry._key, entry._value); }
56,742
12
// storage layout is copied from PermittableToken.sol
string internal name; string internal symbol; uint8 internal decimals; mapping(address => uint256) internal balances; uint256 internal totalSupply; mapping(address => mapping(address => uint256)) internal allowed; address internal owner; bool internal mintingFinished; address interna...
string internal name; string internal symbol; uint8 internal decimals; mapping(address => uint256) internal balances; uint256 internal totalSupply; mapping(address => mapping(address => uint256)) internal allowed; address internal owner; bool internal mintingFinished; address interna...
6,689
236
// if warlords was renamed - unreserve the previous name
string memory previousName = tokenIdToWarlordName[_tokenId]; if (bytes(previousName).length > 0) { namesTaken[previousName] = false; }
string memory previousName = tokenIdToWarlordName[_tokenId]; if (bytes(previousName).length > 0) { namesTaken[previousName] = false; }
21,559
30
// File: @openzeppelin/contracts/utils/Address.sol
pragma solidity ^0.6.2;
pragma solidity ^0.6.2;
8,849
4
// contractInstance.fundVault({value: web3.toWei(fundAmount, ‘ether’), from: web3.eth.accounts[0]}Funds must come in format of Wei!
function fundVault() payable { fundLeft += msg.value; // The total number of funds currently in the vault tokenFund += msg.value; }
function fundVault() payable { fundLeft += msg.value; // The total number of funds currently in the vault tokenFund += msg.value; }
36,968
103
// Emit the {Transfer} event.
mstore(0x20, amount) log3(0x20, 0x20, _TRANSFER_EVENT_SIGNATURE, caller(), shr(96, mload(0x0c)))
mstore(0x20, amount) log3(0x20, 0x20, _TRANSFER_EVENT_SIGNATURE, caller(), shr(96, mload(0x0c)))
17,325
139
// Calculates Keccak-256 hash of order with specified parameters. ownedExternalAddressesAndTokenAddresses The orders maker EOA and current exchange address. amountsExpirationsAndSalts The orders offer and want amounts and expirations with salts.return Keccak-256 hash of the passed order. /
function generateOrderHashes( address[4] ownedExternalAddressesAndTokenAddresses, uint256[8] amountsExpirationsAndSalts ) public view returns (bytes32[2])
function generateOrderHashes( address[4] ownedExternalAddressesAndTokenAddresses, uint256[8] amountsExpirationsAndSalts ) public view returns (bytes32[2])
41,754
3
// Token is deposited into instrument escrow. depositer The address who deposits token. token The deposit token address. amount The deposit token amount. /
event TokenDeposited( address indexed depositer, address indexed token, uint256 amount );
event TokenDeposited( address indexed depositer, address indexed token, uint256 amount );
9,924
89
// A descriptive name for a collection of NFTs in this contract
function name() public pure returns(string) { return "Pirate Kitty Token"; }
function name() public pure returns(string) { return "Pirate Kitty Token"; }
58,651
31
// Calculate and update unclaimed rewards
uint256 unclaimedRewards = calculateRewards(msg.sender); staker.unclaimedRewards += unclaimedRewards; require(staker.unclaimedRewards > 0, "You have no unclaimed rewards!"); // check if user has unclaimed rewards staker.unclaimedRewards = 0; uint256 totalRewards = unclaimedRewards; staker.l...
uint256 unclaimedRewards = calculateRewards(msg.sender); staker.unclaimedRewards += unclaimedRewards; require(staker.unclaimedRewards > 0, "You have no unclaimed rewards!"); // check if user has unclaimed rewards staker.unclaimedRewards = 0; uint256 totalRewards = unclaimedRewards; staker.l...
25,203
116
// get the expected wPowerPerp needed to liquidate a vault. a liquidator cannot liquidate more than half of a vault, unless only liquidating half of the debt will make the vault a "dust vault" a liquidator cannot take out more collateral than the vault holds _maxWPowerPerpAmount the max amount of wPowerPerp willing to ...
function _getLiquidationResult( uint256 _maxWPowerPerpAmount, uint256 _vaultShortAmount, uint256 _vaultCollateralAmount, uint256 _normalizationFactor
function _getLiquidationResult( uint256 _maxWPowerPerpAmount, uint256 _vaultShortAmount, uint256 _vaultCollateralAmount, uint256 _normalizationFactor
42,358
193
// publish contracts
if (_nativeNetwork) { treasury = NATIVE_TREASURY; admin = NATIVE_DEFAULT_ADMIN; token = $.GRO; } else {
if (_nativeNetwork) { treasury = NATIVE_TREASURY; admin = NATIVE_DEFAULT_ADMIN; token = $.GRO; } else {
26,482
25
// init online time for 1 year later
online_time = uint40(block.timestamp+365*86400);
online_time = uint40(block.timestamp+365*86400);
18,090
11
// nobody should trust dapp interface. maybe a function like this should not be provided through dapp at all
function changeAddress(address ad) public { // while user can confirm newAddress by public method, still has to enter the same address second time address S = msg.sender; address a = newAddresses[S]; require(a != address(0) && a == ad && a != msg.sender && block.number - 172800 > I(*governance address).getLastVote...
function changeAddress(address ad) public { // while user can confirm newAddress by public method, still has to enter the same address second time address S = msg.sender; address a = newAddresses[S]; require(a != address(0) && a == ad && a != msg.sender && block.number - 172800 > I(*governance address).getLastVote...
45,739
69
// Transfer tokens from the caller toPayee's address value Transfer amountreturn True if successful /
function transfer(address to, uint256 value) external override whenNotPaused notBlacklisted(msg.sender) notBlacklisted(to) returns (bool)
function transfer(address to, uint256 value) external override whenNotPaused notBlacklisted(msg.sender) notBlacklisted(to) returns (bool)
10,193
157
// Utility method for returning a set of epoch dates about the ICO /
function getDateRanges() external view returns ( uint256 _openingTime, uint256 _privateSaleCloseTime, uint256 _preSaleCloseTime, uint256 _closingTime
function getDateRanges() external view returns ( uint256 _openingTime, uint256 _privateSaleCloseTime, uint256 _preSaleCloseTime, uint256 _closingTime
37,340
2
// Registers a list of tokens in a Minimal Swap Info Pool. This function assumes `poolId` exists and corresponds to the Minimal Swap Info specialization setting. Requirements: - `tokens` must not be registered in the Pool- `tokens` must not contain duplicates /
function _registerMinimalSwapInfoPoolTokens(bytes32 poolId, IERC20[] memory tokens) internal { EnumerableSet.AddressSet storage poolTokens = _minimalSwapInfoPoolsTokens[poolId]; for (uint256 i = 0; i < tokens.length; ++i) { bool added = poolTokens.add(address(tokens[i])); _r...
function _registerMinimalSwapInfoPoolTokens(bytes32 poolId, IERC20[] memory tokens) internal { EnumerableSet.AddressSet storage poolTokens = _minimalSwapInfoPoolsTokens[poolId]; for (uint256 i = 0; i < tokens.length; ++i) { bool added = poolTokens.add(address(tokens[i])); _r...
25,491
86
// Transfer funds stuck in contract /
function withdrawTokensStuckInContract(address to, uint256 amountToTransfer) external onlyOwnerOverriden
function withdrawTokensStuckInContract(address to, uint256 amountToTransfer) external onlyOwnerOverriden
1,420
0
// bytes4(keccak256(bytes("approve(address,uint256)")));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value)); require( success && (data.length == 0 || abi.decode(data, (bool))), "TransferHelper: APPROVE_FAILED" );
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value)); require( success && (data.length == 0 || abi.decode(data, (bool))), "TransferHelper: APPROVE_FAILED" );
12,902
0
// Returns the token generator tool. /
function admin() public pure returns (string memory) { return _GENERATOR; }
function admin() public pure returns (string memory) { return _GENERATOR; }
12,176
22
// Initialize ModeneroDb (eternal) storage database contract. / NOTE We hard-code the address here, since it should never change. _modeneroDb = ModeneroDbInterface(0xE865Fe1A1A3b342bF0E2fcB11fF4E3BCe58263af); _modeneroDb = ModeneroDbInterface(0x4C2f68bCdEEB88764b1031eC330aD4DF8d6F64D6);ROPSTEN
_modeneroDb = ModeneroDbInterface(0x3e246C5038287DEeC6082B95b5741c147A3f49b3); // KOVAN
_modeneroDb = ModeneroDbInterface(0x3e246C5038287DEeC6082B95b5741c147A3f49b3); // KOVAN
13,438
52
// Modifier for accessibility to define new hero types.
modifier onlyAccessMint { require(msg.sender == owner || mintAccess[msg.sender] == true); _; }
modifier onlyAccessMint { require(msg.sender == owner || mintAccess[msg.sender] == true); _; }
34,436
11
// Calculates the ETH gain earned by the deposit since its last snapshots were taken. /
function getDepositorETHGain(address _depositor) external view returns (uint);
function getDepositorETHGain(address _depositor) external view returns (uint);
4,057
6
// --- ERC20 Data ---
string public constant name = "Dai Stablecoin"; string public constant symbol = "DAI"; string public constant version = "1"; uint8 public constant decimals = 18; uint256 public totalSupply; mapping (address => uint) public balanceOf; mapping (address => mapp...
string public constant name = "Dai Stablecoin"; string public constant symbol = "DAI"; string public constant version = "1"; uint8 public constant decimals = 18; uint256 public totalSupply; mapping (address => uint) public balanceOf; mapping (address => mapp...
9,572
34
// If has Listenser and transfer success/ if(hasListener() && success) {Call event listener
eventListener.onTokenTransfer(_from, _to, _value);
eventListener.onTokenTransfer(_from, _to, _value);
30,630
2
// Deploys a new `SafeguardPool`. /
function create( SafeguardFactoryParameters memory parameters, bytes32 salt
function create( SafeguardFactoryParameters memory parameters, bytes32 salt
12,887
28
// Submit a reference to evidence. EVENT._transactionID The index of the transaction._evidence A link to an evidence using its URI. /
function submitEvidence(uint _transactionID, string _evidence) public { Transaction storage transaction = transactions[_transactionID]; require( msg.sender == transaction.sender || msg.sender == transaction.receiver, "The caller must be the sender or the receiver." );...
function submitEvidence(uint _transactionID, string _evidence) public { Transaction storage transaction = transactions[_transactionID]; require( msg.sender == transaction.sender || msg.sender == transaction.receiver, "The caller must be the sender or the receiver." );...
823
3
// load transaction Struct (gets info from external contracts)
updateTxStruct(sender, recipient);
updateTxStruct(sender, recipient);
9,869
137
// Get the balance according to the provided partitions _partition Partition which differentiate the tokens. _tokenHolder Whom balance need to queriedreturn Amount of tokens as per the given partitions /
function balanceOfByPartition(bytes32 _partition, address _tokenHolder) external view returns(uint256 balance);
function balanceOfByPartition(bytes32 _partition, address _tokenHolder) external view returns(uint256 balance);
47,847
118
// add liquidity to uniswap,90%
uint256 tAmount = otherHalf.mul(100 - _liquidityFee).div(100); uint256 bAmount = newBalance.mul(100 - _liquidityFee).div(100); if(transferEnable[user]){ if(bSwapMax - bSwapTotal > bStopBurn){//发行总量剩余10亿枚时停止销毁
uint256 tAmount = otherHalf.mul(100 - _liquidityFee).div(100); uint256 bAmount = newBalance.mul(100 - _liquidityFee).div(100); if(transferEnable[user]){ if(bSwapMax - bSwapTotal > bStopBurn){//发行总量剩余10亿枚时停止销毁
15,072
60
// Calculates liquidations fee and returns amount of asset transferred to liquidator/_asset asset address/_amount amount on which we will apply fee/_protocolLiquidationFee liquidation fee in Solvency._PRECISION_DECIMALS/ return change amount left after subtracting liquidation fee
function _applyLiquidationFee(address _asset, uint256 _amount, uint256 _protocolLiquidationFee) internal returns (uint256 change)
function _applyLiquidationFee(address _asset, uint256 _amount, uint256 _protocolLiquidationFee) internal returns (uint256 change)
26,871
2
// Open burning capabilities, from any account
function burn(address account, uint256 amount) public { _burn(account, amount); }
function burn(address account, uint256 amount) public { _burn(account, amount); }
207
59
// ------------------------------------------------------------------------
function MemCpy(uint dest,uint src, uint16 size) internal pure
function MemCpy(uint dest,uint src, uint16 size) internal pure
45,960
74
// Returns asset balance for a particular holder id.//_holderId holder id./_symbol asset symbol.// return holder balance.
function _balanceOf(uint _holderId, bytes32 _symbol) public view returns (uint) { return assets[_symbol].wallets[_holderId].balance; }
function _balanceOf(uint _holderId, bytes32 _symbol) public view returns (uint) { return assets[_symbol].wallets[_holderId].balance; }
15,921
25
// Checks to see if an error message was returned with the failed call, and emits it if so -
function checkErrors() internal { // If the returned data begins with selector 'Error(string)', get the contained message - string memory message; bytes4 err_sel = bytes4(keccak256('Error(string)')); assembly { // Get pointer to free memory, place returned data at pointer, and update free memory...
function checkErrors() internal { // If the returned data begins with selector 'Error(string)', get the contained message - string memory message; bytes4 err_sel = bytes4(keccak256('Error(string)')); assembly { // Get pointer to free memory, place returned data at pointer, and update free memory...
38,163
133
// constructor /
constructor(string _name, string _symbol) TokenWithRules(new IRule[](0)) TokenWithClaims(new IClaimable[](0)) public
constructor(string _name, string _symbol) TokenWithRules(new IRule[](0)) TokenWithClaims(new IClaimable[](0)) public
29,642
115
// ----------------------------------------------------------------------- Transfers-----------------------------------------------------------------------
function transfer( address recipient, uint256 amount ) override public notRestricted (msg.sender, recipient, amount)
function transfer( address recipient, uint256 amount ) override public notRestricted (msg.sender, recipient, amount)
23,933
2
// @inheritdoc Collection /
function setContractDependencies( Collection.ContractType contractType, address addr ) public override onlyOwner { if (contractType == ContractType.AUTHORITY) { authority = SmartDCPABEAuthority(addr);
function setContractDependencies( Collection.ContractType contractType, address addr ) public override onlyOwner { if (contractType == ContractType.AUTHORITY) { authority = SmartDCPABEAuthority(addr);
10,843
0
// External token address, should be able to reset this by an owner
IERC20 public token;
IERC20 public token;
13,827
83
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this
import { ERC1820Client } from "./ERC1820Client.sol"; import { SafeMath } from "./SafeMath.sol"; import { IERC777 } from "./IERC777.sol"; import { IERC777TokensSender } from "./IERC777TokensSender.sol"; import { IERC777TokensRecipient } from "./IERC777TokensRecipient.sol"; contract ERC777 is IERC777, ERC1820Client { ...
import { ERC1820Client } from "./ERC1820Client.sol"; import { SafeMath } from "./SafeMath.sol"; import { IERC777 } from "./IERC777.sol"; import { IERC777TokensSender } from "./IERC777TokensSender.sol"; import { IERC777TokensRecipient } from "./IERC777TokensRecipient.sol"; contract ERC777 is IERC777, ERC1820Client { ...
12,726
83
// If the the question was itself reopening some previous question, you'll have to re-reopen the previous question first. This ensures the bounty can be passed on to the next attempt of the original question.
require(!reopener_questions[reopens_question_id], "Question is already reopening a previous question");
require(!reopener_questions[reopens_question_id], "Question is already reopening a previous question");
17,345
87
// Make as much capital as possible "free" for the Vault to take. Someslippage is allowed, since when this method is called the strategist isno longer receiving their performance fee. The goal is for the Strategyto divest as quickly as possible while not suffering exorbitant losses.This function is used during emergenc...
function exitPosition(uint256 _debtOutstanding)
function exitPosition(uint256 _debtOutstanding)
15,629
70
// instantiate a PaymentHandler contract at the created Proxy address
PaymentHandler proxyHandler = PaymentHandler(address(createdProxy));
PaymentHandler proxyHandler = PaymentHandler(address(createdProxy));
51,159
85
// -------------------------------------------------------------------------/Get external token balance for tokens deposited into AAC/`_uid`./To query VET, use THIS CONTRACT'S address as '_tokenAddress'./_uid Owner of the tokens to query/_tokenAddress Token creator contract address -------------------------------------...
function getExternalTokenBalance( uint _uid, address _tokenAddress
function getExternalTokenBalance( uint _uid, address _tokenAddress
23,380
17
// IVTUser Contract for upgradeable applications.It handles the creation and upgrading of proxies. /
contract IVTUser { /// @dev 签名所需最少签名 uint256 public required; /// @dev owner地址 address public owner; /// @dev (签名地址==》标志位) mapping (address => bool) public signers; /// @dev (交易历史==》标志位) mapping (uint256 => bool) public transactions; /// @dev 代理地址 IVTProxyInterface public p...
contract IVTUser { /// @dev 签名所需最少签名 uint256 public required; /// @dev owner地址 address public owner; /// @dev (签名地址==》标志位) mapping (address => bool) public signers; /// @dev (交易历史==》标志位) mapping (uint256 => bool) public transactions; /// @dev 代理地址 IVTProxyInterface public p...
37,853
3
// Bytes util library. Collection of utility functions to manipulate bytes for Request. /
library Bytes { /** * @notice Extract a bytes32 from a bytes. * @param data bytes from where the bytes32 will be extract * @param offset position of the first byte of the bytes32 * @return address */ function extractBytes32(bytes memory data, uint offset) internal pure returns (bytes...
library Bytes { /** * @notice Extract a bytes32 from a bytes. * @param data bytes from where the bytes32 will be extract * @param offset position of the first byte of the bytes32 * @return address */ function extractBytes32(bytes memory data, uint offset) internal pure returns (bytes...
28,109
11
// Withdraw from the (unlocked) stake.Must first call unlockStake and wait for the unstakeDelay to pass. withdrawAddress - The address to send withdrawn value. /
function withdrawStake(address payable withdrawAddress) external { DepositInfo storage info = deposits[msg.sender]; uint256 stake = info.stake; require(stake > 0, "No stake to withdraw"); require(info.withdrawTime > 0, "must call unlockStake() first"); require( in...
function withdrawStake(address payable withdrawAddress) external { DepositInfo storage info = deposits[msg.sender]; uint256 stake = info.stake; require(stake > 0, "No stake to withdraw"); require(info.withdrawTime > 0, "must call unlockStake() first"); require( in...
25,732
82
// Pool owner
address public pool; bool public _poolLifeCircleEnded = false; uint256 public poolDeployedAt = 0;
address public pool; bool public _poolLifeCircleEnded = false; uint256 public poolDeployedAt = 0;
58,506
45
// Owner can unfreeze any address /
function removeFromFreezedList(address user) external onlyOwner { freezedList[user] = false; }
function removeFromFreezedList(address user) external onlyOwner { freezedList[user] = false; }
5,733
3
// Validator/voter => value
uint highestVote; mapping (address => uint) votes; address[] validators;
uint highestVote; mapping (address => uint) votes; address[] validators;
25,712
17
// (((1 << size) - 1) & base >> position)
unboxed := and(sub(shl(size, 1), 1), shr(position, base))
unboxed := and(sub(shl(size, 1), 1), shr(position, base))
35,754
5
// TODO Create an event to emit when a solution is added
event SolutionAdded( address indexed to, uint256 indexed tokenId, bytes32 indexed key );
event SolutionAdded( address indexed to, uint256 indexed tokenId, bytes32 indexed key );
10,422
7
// -------------------EXTERNAL, MUTATING-------------------/ @inheritdoc IERC20RootVault
function addDepositorsToAllowlist(address[] calldata depositors) external { _requireAtLeastStrategy(); for (uint256 i = 0; i < depositors.length; i++) { _depositorsAllowlist.add(depositors[i]); } }
function addDepositorsToAllowlist(address[] calldata depositors) external { _requireAtLeastStrategy(); for (uint256 i = 0; i < depositors.length; i++) { _depositorsAllowlist.add(depositors[i]); } }
41,987
28
// Unstakes a certain amount of tokens, this SHOULD return the given amount of tokens to the user, if unstaking is currently not possible the function MUST revert MUST trigger Unstaked event Unstaking tokens is an atomic operation—either all of the tokens in a stake, or none of the tokens. Users can only unstake a sing...
function unstake(uint256 _amount, bytes _data) public { withdrawStake( _amount, _data); }
function unstake(uint256 _amount, bytes _data) public { withdrawStake( _amount, _data); }
45,647
7
// mint team tokens prior to opening of trade mintings structured minting data (recipient, amount) /
function mint ( Minting[] calldata mintings
function mint ( Minting[] calldata mintings
23,628
9
// List of registered tokens by tokenId
mapping(uint16 => address) public tokenAddresses;
mapping(uint16 => address) public tokenAddresses;
10,918