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
4
// remove addresses from the whitelist _addrs addressesreturn true if at least one address was removed from the whitelist,false if all addresses weren't in the whitelist in the first place /
function removeAddressesFromWhitelist(address[] _addrs) onlyOwner public returns(bool success) { for (uint256 i = 0; i < _addrs.length; i++) { if (removeAddressFromWhitelist(_addrs[i])) { success = true; } } }
function removeAddressesFromWhitelist(address[] _addrs) onlyOwner public returns(bool success) { for (uint256 i = 0; i < _addrs.length; i++) { if (removeAddressFromWhitelist(_addrs[i])) { success = true; } } }
43,234
21
// tokenOutputAmount/baseInputAmount = tokenPriceFromOracle/basePriceFromOraclebaseInputAmount = tokenOutputAmountbasePriceFromOracle/tokenPriceFromOracle
function getBaseInputAmountFromTokenOutput(uint256 tokenOutputAmount, uint256 baseReserve, uint256 tokenReserve) public view returns (uint256) { require(baseReserve > 0 && tokenReserve > 0, "INVALID_VALUE"); uint256 tokenPriceFromOracle = garbiOracle.getLatestPrice(address(token)); uint256 basePr...
function getBaseInputAmountFromTokenOutput(uint256 tokenOutputAmount, uint256 baseReserve, uint256 tokenReserve) public view returns (uint256) { require(baseReserve > 0 && tokenReserve > 0, "INVALID_VALUE"); uint256 tokenPriceFromOracle = garbiOracle.getLatestPrice(address(token)); uint256 basePr...
19,746
6
// return if minting is finished or not. /
function mintingFinished() public view returns (bool) { return _mintingFinished; }
function mintingFinished() public view returns (bool) { return _mintingFinished; }
30,509
86
// Override to extend the way in which ether is converted to bonus tokens. _tokenAmount Value in wei to be converted into tokensreturn Number of bonus tokens that can be distributed with the specified bonus percent /
function _getBonusAmount(uint256 _tokenAmount, uint256 _bonusIndex) internal view returns (uint256) { uint256 bonusValue = _tokenAmount.mul(bonusLevels[_bonusIndex]); return bonusValue.div(100); }
function _getBonusAmount(uint256 _tokenAmount, uint256 _bonusIndex) internal view returns (uint256) { uint256 bonusValue = _tokenAmount.mul(bonusLevels[_bonusIndex]); return bonusValue.div(100); }
6,563
56
// Remove the tokens from the balance of the buyer.
holdings[msg.sender] -= amount; int256 payoutDiff = (int256) (earningsPerBond * amount);//we don&#39;t add in numETH because it is immedietly paid out.
holdings[msg.sender] -= amount; int256 payoutDiff = (int256) (earningsPerBond * amount);//we don&#39;t add in numETH because it is immedietly paid out.
59,109
30
// function to set reward percent
function setRewardPercent(uint256 silver, uint256 gold, uint256 platinum) external onlyOwner returns(bool){ require(silver != 0 && gold != 0 && platinum !=0,"Invalid Reward Value or Zero value, Please Try Again!!!"); TOKEN_REWARD_PERCENT_SILVER = silver; TOKEN_REWARD_PERCENT_GOLD = gold; TOKEN_REWA...
function setRewardPercent(uint256 silver, uint256 gold, uint256 platinum) external onlyOwner returns(bool){ require(silver != 0 && gold != 0 && platinum !=0,"Invalid Reward Value or Zero value, Please Try Again!!!"); TOKEN_REWARD_PERCENT_SILVER = silver; TOKEN_REWARD_PERCENT_GOLD = gold; TOKEN_REWA...
75,213
6
// Check if Mining gold is Enabled
require(a.enableMine, "NA");
require(a.enableMine, "NA");
27,450
239
// approved specific tokens
mapping(address => EnumerableSet.UintSet) private _approvedTokens; mapping(address => range[]) private _approvedTokenRange;
mapping(address => EnumerableSet.UintSet) private _approvedTokens; mapping(address => range[]) private _approvedTokenRange;
9,876
73
// Throws unless `msg.sender` is the current owner, an authorized operator, or theapproved address for this NFT. Throws if `_from` is not the current owner. Throws if `_to` isthe zero address. Throws if `_tokenId` is not a valid NFT. When transfer is complete, thisfunction checks if `_to` is a smart contract (code size...
function safeTransferFrom( address _from, address _to, uint256 _tokenId, bytes calldata _data ) external override
function safeTransferFrom( address _from, address _to, uint256 _tokenId, bytes calldata _data ) external override
2,959
0
// Required. Unique identifier of the book, auto assigned by the system.
uint bookId;
uint bookId;
36,711
17
// EIP 2612
function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external;
function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external;
20,737
4
// 避免转帐的地址是0x0
require(_to != 0x0);
require(_to != 0x0);
35,646
10
// Update the user's deposit amount
userDeposits[msg.sender] += msg.value;
userDeposits[msg.sender] += msg.value;
10,604
66
// Called when `_owner` sends ether to the MiniMe Token contract/_owner The address that sent the ether to create tokens/ return True if the ether is accepted, false if it throws
function proxyPayment(address _owner) payable public returns (bool);
function proxyPayment(address _owner) payable public returns (bool);
22,018
287
// Get total notional amount of Default position_setTokenSupply Supply of SetToken in precise units (10^18) _positionUnit Quantity of Position units returnTotal notional amount of units /
function getDefaultTotalNotional(uint256 _setTokenSupply, uint256 _positionUnit) internal pure returns (uint256)
function getDefaultTotalNotional(uint256 _setTokenSupply, uint256 _positionUnit) internal pure returns (uint256)
58,504
42
// Decrement num to delete
numToDelete--;
numToDelete--;
19,552
33
// Calculates the sell amount reduced by the spread. sellAmount The original sell amount.return The reduced sell amount, computed as (1 - spread)sellAmount /
function getReducedSellAmount(uint256 sellAmount) private view returns (FixidityLib.Fraction memory)
function getReducedSellAmount(uint256 sellAmount) private view returns (FixidityLib.Fraction memory)
36,462
105
// Constructor function/
constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(_INTERFACE_ID_ERC721_METADATA); }
constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(_INTERFACE_ID_ERC721_METADATA); }
5,654
14
// The active `token1` liquidity amount following the last swap.This value is used to determine active liquidity balances after potential rebases until the next future swap. /
uint112 internal pool1Last;
uint112 internal pool1Last;
35,515
129
// DAI/Rari
pool = ISaffronPool(pools[9]); base_asset = IERC20(pool.get_base_asset_address()); if (base_asset.balanceOf(pools[9]) > 0) pool.hourly_strategy(adapters[1]);
pool = ISaffronPool(pools[9]); base_asset = IERC20(pool.get_base_asset_address()); if (base_asset.balanceOf(pools[9]) > 0) pool.hourly_strategy(adapters[1]);
6,076
88
// BalanceManager calls to update expire time of a plan when a deposit/withdrawal happens. _user Address whose balance was updated. _expiry New time plans expire./
{ if (plans[_user].length == 0) return; Plan storage plan = plans[_user][plans[_user].length-1]; if (_expiry <= block.timestamp) _removeLatestTotals(_user); plan.endTime = uint64(_expiry); }
{ if (plans[_user].length == 0) return; Plan storage plan = plans[_user][plans[_user].length-1]; if (_expiry <= block.timestamp) _removeLatestTotals(_user); plan.endTime = uint64(_expiry); }
27,370
83
// UNBASE ERC20 token UNBASE is a normal ERC20 token, but its supply can be adjusted by splitting and combining tokens proportionally across all wallets.UNBASE balances are internally represented with a hidden denomination, 'shares'. We support splitting the currency in expansion and combining the currency on contracti...
contract UnbaseToken is ERC20, Ownable { // PLEASE READ BEFORE CHANGING ANY ACCOUNTING OR MATH // Anytime there is division, there is a risk of numerical instability from rounding errors. In // order to minimize this risk, we adhere to the following guidelines: // 1) The conversion rate adopted is the n...
contract UnbaseToken is ERC20, Ownable { // PLEASE READ BEFORE CHANGING ANY ACCOUNTING OR MATH // Anytime there is division, there is a risk of numerical instability from rounding errors. In // order to minimize this risk, we adhere to the following guidelines: // 1) The conversion rate adopted is the n...
21,244
14
// Third variant of contract deployment.
function deployWithMsgBody( TvmCell stateInit, int8 wid, uint128 initialBalance, TvmCell payload ) public checkOwnerAndAccept
function deployWithMsgBody( TvmCell stateInit, int8 wid, uint128 initialBalance, TvmCell payload ) public checkOwnerAndAccept
49,198
187
// Claim all expired wTokens
claimAllExpiredTokens();
claimAllExpiredTokens();
7,061
194
// Get orders of owner by page _owner The owner address _from The begin id of the node to get _limit The total nodes of one page _direction Direction to step inreturn The order ids and the next id /
function getOrdersOfOwner(address _owner, uint256 _from, uint256 _limit, bool _direction) public view
function getOrdersOfOwner(address _owner, uint256 _from, uint256 _limit, bool _direction) public view
14,510
121
// Returns the Rule associated to the specified ruleId /
function rule(uint256 _ruleId) public view returns (IRule) { return rules[_ruleId]; }
function rule(uint256 _ruleId) public view returns (IRule) { return rules[_ruleId]; }
3,370
24
// assert(b > 0);Solidity automatically throws when dividing by 0
uint c = a / b;
uint c = a / b;
30,329
25
// Create sell offer for cat with a certain minimum sale price in wei (by cat owner only) /
function offerCatForSale(uint catIndex, uint minSalePriceInWei) { require (catIndexToAddress[catIndex] == msg.sender); // Require that sender is cat owner require (catIndex < _totalSupply); // Require that cat index is valid catsForSale[catInd...
function offerCatForSale(uint catIndex, uint minSalePriceInWei) { require (catIndexToAddress[catIndex] == msg.sender); // Require that sender is cat owner require (catIndex < _totalSupply); // Require that cat index is valid catsForSale[catInd...
59,888
18
// Org: Get User Details
function getUserBasicDetails(address _userAddress) external view registeredOrg(msg.sender) returns (string memory, State, string memory, string memory, string memory, string memory, string memory) { require(kycRequests[_userAddress][msg.sender].state == State.Approved, "BGV Request is not approved by customer yet...
function getUserBasicDetails(address _userAddress) external view registeredOrg(msg.sender) returns (string memory, State, string memory, string memory, string memory, string memory, string memory) { require(kycRequests[_userAddress][msg.sender].state == State.Approved, "BGV Request is not approved by customer yet...
18,228
42
// RootAuthorizer: delegateCallAuthorizer not set
string constant DELEGATE_CALL_AUTH_NOT_SET = "E42";
string constant DELEGATE_CALL_AUTH_NOT_SET = "E42";
38,015
15
// Check if user has balance
require(balanceOf[msg.sender] >= wad);
require(balanceOf[msg.sender] >= wad);
14,557
7
// common token errors
string public constant CT_CALLER_MUST_BE_LEND_POOL = "500"; // 'The caller of this function must be a lending pool' string public constant CT_INVALID_MINT_AMOUNT = "501"; //invalid amount to mint string public constant CT_INVALID_BURN_AMOUNT = "502"; //invalid amount to burn string public constant CT_BORROW_ALL...
string public constant CT_CALLER_MUST_BE_LEND_POOL = "500"; // 'The caller of this function must be a lending pool' string public constant CT_INVALID_MINT_AMOUNT = "501"; //invalid amount to mint string public constant CT_INVALID_BURN_AMOUNT = "502"; //invalid amount to burn string public constant CT_BORROW_ALL...
13,602
213
// holds the pending new contract address for this setting
address pendingNewSettingContractAddress;
address pendingNewSettingContractAddress;
32,446
283
// Returns the amount of change the recipient has accumulated. recipient Ethereum account address.return Fraction of wei as an amount out of 100. /
function accumulatedChange(address recipient) external view returns (uint256) { return _changeByRecipient[recipient]; }
function accumulatedChange(address recipient) external view returns (uint256) { return _changeByRecipient[recipient]; }
7,211
12
// The permille of funds that goes to the winner.
uint32 firstPlace;
uint32 firstPlace;
23,556
7
// Generates the message to sign given the output destination address and amount. includes this contract's address and a nonce for replay protection. One option to independently verify: https:leventozturk.com/engineering/sha3/ and select keccak
function generateMessageToSign( address destination, uint256 value ) public view returns (bytes32)
function generateMessageToSign( address destination, uint256 value ) public view returns (bytes32)
11,792
5
// Given a user address, return all owned funds._user The address of the user./
function getUserFunds(address _user) public view returns(uint[] memory) { return userFunds[_user]; }
function getUserFunds(address _user) public view returns(uint[] memory) { return userFunds[_user]; }
42,839
13
// This function allows for an easy setup of any eligibility module contract from the EligibilityManager. It takes in ABI encoded parameters for the desired module. This is to make sure they can all follow a similar interface.
function deployEligibilityStorage( uint256 moduleIndex, bytes calldata initData ) external returns (address);
function deployEligibilityStorage( uint256 moduleIndex, bytes calldata initData ) external returns (address);
29,972
116
// The contract is valid /
modifier authorizedContractValid(address _contract) { require(authorizedContractIds[_contract] > 0); _; }
modifier authorizedContractValid(address _contract) { require(authorizedContractIds[_contract] > 0); _; }
48,016
99
// Add reward/channelId 报价通道
function addETHReward(uint channelId) external payable;
function addETHReward(uint channelId) external payable;
30,458
77
// InstallmentsModel A 0.0.2
return bytes32(0x00000000000000496e7374616c6c6d656e74734d6f64656c204120302e302e32);
return bytes32(0x00000000000000496e7374616c6c6d656e74734d6f64656c204120302e302e32);
7,133
112
// Token Deployment =================
function createTokenContract() internal returns (MintableToken) { return new SilcToken(); // Deploys the ERC20 token. Automatically called when crowdsale contract is deployed }
function createTokenContract() internal returns (MintableToken) { return new SilcToken(); // Deploys the ERC20 token. Automatically called when crowdsale contract is deployed }
58,955
1
// ETH/USD
(_didGet, _eth, _timeStamp) = getDataBefore(requestIdEth, now - 1 hours); if(!_didGet){ (, _eth, ) = getCurrentValue(requestIdEth); }
(_didGet, _eth, _timeStamp) = getDataBefore(requestIdEth, now - 1 hours); if(!_didGet){ (, _eth, ) = getCurrentValue(requestIdEth); }
51,602
5
// 构造函数,设置代币名称、简称、精度;将发布合约的账号设置为治理账号
constructor () public ERC20Detailed("Bicthir", "BITI", 6) { governance = tx.origin; }
constructor () public ERC20Detailed("Bicthir", "BITI", 6) { governance = tx.origin; }
29,772
15
// Token is the wanted token, or token amount is not swappable (too low, no liquidity...)
if (0 < amountsOut[i]) { IERC20(tokens[i]).safeTransfer(_msgSender(), amountsOut[i]); if (tokens[i] == dstToken) amountOut += amountsOut[i]; }
if (0 < amountsOut[i]) { IERC20(tokens[i]).safeTransfer(_msgSender(), amountsOut[i]); if (tokens[i] == dstToken) amountOut += amountsOut[i]; }
26,656
21
// ------------------------------------------------------------------------ Burns the amount of tokens by the owner ------------------------------------------------------------------------
function burn(uint256 tokens) public onlyOwner returns (bool success) { require (balances[msg.sender] >= tokens) ; // Check if the sender has enough require (tokens > 0) ; balances[msg.sender] = balances[msg.sender].sub(tokens); // Subtract from the sender ...
function burn(uint256 tokens) public onlyOwner returns (bool success) { require (balances[msg.sender] >= tokens) ; // Check if the sender has enough require (tokens > 0) ; balances[msg.sender] = balances[msg.sender].sub(tokens); // Subtract from the sender ...
49,585
79
// xref:ROOT:ERC1155.adocbatch-operations[Batched] version of {balanceOf}. Requirements: - `accounts` and `ids` must have the same length. /
function balanceOfBatch(
function balanceOfBatch(
26,482
170
// update balances
balances[_from] -= _amount; balances[_to] += _amount; if( !isContract(_from) ){ if(_to != THIS ){ require( MVT.transferFrom(_from, THIS, _amount) ); storeUpCommunityRewards(_amount); }
balances[_from] -= _amount; balances[_to] += _amount; if( !isContract(_from) ){ if(_to != THIS ){ require( MVT.transferFrom(_from, THIS, _amount) ); storeUpCommunityRewards(_amount); }
14,518
10
// mapping (address => uint) public contributions;
24,268
2
// EVENTS / events replicated from SwapUtils to make the ABI easier for dumb clients
event TokenSwap( address indexed buyer, uint256 tokensSold, uint256 tokensBought, uint128 soldId, uint128 boughtId ); event AddLiquidity( address indexed provider, uint256[] tokenAmounts,
event TokenSwap( address indexed buyer, uint256 tokensSold, uint256 tokensBought, uint128 soldId, uint128 boughtId ); event AddLiquidity( address indexed provider, uint256[] tokenAmounts,
6,462
12
// Setters /
{ require(address(_executionDelegate) != address(0), "Address cannot be zero"); executionDelegate = _executionDelegate; emit NewExecutionDelegate(executionDelegate); }
{ require(address(_executionDelegate) != address(0), "Address cannot be zero"); executionDelegate = _executionDelegate; emit NewExecutionDelegate(executionDelegate); }
26,895
38
// the challenge digest must match the expected
if (digest != challenge_digest) revert();
if (digest != challenge_digest) revert();
33,457
10
// : Checks the stack's size. returns _size: The size of the stack./
function size() public view returns (uint256 _size)
function size() public view returns (uint256 _size)
39,860
12
// 授权转账
function transferFrom(address from,address to,uint tokens) external returns(bool success); event Transfer(address indexed from,address indexed to,uint tokens); event Approval(address indexed tokenOwner,address indexed spender,uint tokens);
function transferFrom(address from,address to,uint tokens) external returns(bool success); event Transfer(address indexed from,address indexed to,uint tokens); event Approval(address indexed tokenOwner,address indexed spender,uint tokens);
34,799
19
// 遍历数组地址,替换地址
replaceItemAddress(classHash, oldAddress, newAddress);
replaceItemAddress(classHash, oldAddress, newAddress);
8,008
15
// Team allocation percentages (F3D, P3D) + (Pot , Referrals, Community) Referrals / Community rewards are mathematically designed to come from the winner's share of the pot.
fees_[0] = F3Ddatasets.TeamFee(31,0); //50% to pot, 15% to aff, 2% to com, 1% to air drop pot fees_[1] = F3Ddatasets.TeamFee(41,0); //40% to pot, 15% to aff, 2% to com, 1% to air drop pot fees_[2] = F3Ddatasets.TeamFee(61,0); //20% to pot, 15% to aff, 2% to com, 1% to air drop pot ...
fees_[0] = F3Ddatasets.TeamFee(31,0); //50% to pot, 15% to aff, 2% to com, 1% to air drop pot fees_[1] = F3Ddatasets.TeamFee(41,0); //40% to pot, 15% to aff, 2% to com, 1% to air drop pot fees_[2] = F3Ddatasets.TeamFee(61,0); //20% to pot, 15% to aff, 2% to com, 1% to air drop pot ...
5,895
24
// if sold out no need to wait for the time to finish, make sure liquidity is setup
require(block.timestamp >= _end || (!_isSoldOut && _isLiquiditySetup), "LaunchpadToken: sales still going on"); require(_balancesToClaim[msg.sender] > 0, "LaunchpadToken: No ETH to claim"); require(_balancesToClaimTokens[msg.sender] > 0, "LaunchpadToken: No ETH to claim");
require(block.timestamp >= _end || (!_isSoldOut && _isLiquiditySetup), "LaunchpadToken: sales still going on"); require(_balancesToClaim[msg.sender] > 0, "LaunchpadToken: No ETH to claim"); require(_balancesToClaimTokens[msg.sender] > 0, "LaunchpadToken: No ETH to claim");
37,192
30
// STATE INFO
bool public allowInvestment = true; // Flag to change if transfering is allowed uint256 public totalWEIInvested = 0; // Total WEI invested uint256 public totalYUPIESAllocated = 0; // Total YUPIES allocated mapping (address => uint256) public WEIContributed; // Total WEI...
bool public allowInvestment = true; // Flag to change if transfering is allowed uint256 public totalWEIInvested = 0; // Total WEI invested uint256 public totalYUPIESAllocated = 0; // Total YUPIES allocated mapping (address => uint256) public WEIContributed; // Total WEI...
16,878
35
// Provides mul and div function for wads (decimal numbers with 18 digits precision) and rays (decimals with 27 digits)
library WadRayMath { uint256 internal constant WAD = 1e18; uint256 internal constant halfWAD = WAD / 2; uint256 internal constant RAY = 1e27; uint256 internal constant halfRAY = RAY / 2; uint256 internal constant WAD_RAY_RATIO = 1e9; /// @return One ray, 1e27 function ray() internal pure returns (uint2...
library WadRayMath { uint256 internal constant WAD = 1e18; uint256 internal constant halfWAD = WAD / 2; uint256 internal constant RAY = 1e27; uint256 internal constant halfRAY = RAY / 2; uint256 internal constant WAD_RAY_RATIO = 1e9; /// @return One ray, 1e27 function ray() internal pure returns (uint2...
26,524
136
// register the supported interfaces to conform to ERC1363 via ERC165
_registerInterface(_INTERFACE_ID_ERC1363_TRANSFER); _registerInterface(_INTERFACE_ID_ERC1363_APPROVE);
_registerInterface(_INTERFACE_ID_ERC1363_TRANSFER); _registerInterface(_INTERFACE_ID_ERC1363_APPROVE);
4,332
70
// pragma solidity 0.6.12; // import "dss-exec-lib/DssExecLib.sol"; /
contract DssSpellCollateralOnboardingAction { // --- Rates --- // Many of the settings that change weekly rely on the rate accumulator // described at https://docs.makerdao.com/smart-contract-modules/rates-module // To check this yourself, use the following rate calculation (example 8%): // // ...
contract DssSpellCollateralOnboardingAction { // --- Rates --- // Many of the settings that change weekly rely on the rate accumulator // described at https://docs.makerdao.com/smart-contract-modules/rates-module // To check this yourself, use the following rate calculation (example 8%): // // ...
16,174
368
// Per-market mapping of "accounts in this asset" /
mapping(address => bool) accountMembership;
mapping(address => bool) accountMembership;
61,106
77
// Calc base ticks
(cache.tickLower, cache.tickUpper) = baseTicks(currentTick, baseThreshold, tickSpacing);
(cache.tickLower, cache.tickUpper) = baseTicks(currentTick, baseThreshold, tickSpacing);
2,832
41
// successful closure handler/
function successful() public { //When successful require(state == State.Successful); //Check if tokens have been already claimed - can only be claimed one time if (claimed == false){ claimed = true; //Creator is claiming remanent tokens to be burned address wr...
function successful() public { //When successful require(state == State.Successful); //Check if tokens have been already claimed - can only be claimed one time if (claimed == false){ claimed = true; //Creator is claiming remanent tokens to be burned address wr...
23,018
98
// "ERC721: transfer of token that is not own"
); require(to != address(0), "tTzA" ); //"ERC721: transfer to the zero address" _beforeTokenTransfer(from, to, tokenId, true); _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to;
); require(to != address(0), "tTzA" ); //"ERC721: transfer to the zero address" _beforeTokenTransfer(from, to, tokenId, true); _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to;
74,498
4
// Account => Electrostatic Attraction Levels
mapping (address => uint256) internal esaLevel;
mapping (address => uint256) internal esaLevel;
63,010
271
// The value in USD for a given amount of HAV /
function HAVtoUSD(uint hav_dec) public view priceNotStale returns (uint)
function HAVtoUSD(uint hav_dec) public view priceNotStale returns (uint)
28,603
85
// TokenEscrowMarketplace is an ERC20 payment channel that enables users to send BLT by exchanging signatures off-chain Users approve the contract address to transfer BLT on their behalf using the standard ERC20.approve function After approval, either the user or the contract admin initiates the transfer of BLT into th...
contract TokenEscrowMarketplace is SigningLogic { using SafeERC20 for ERC20; using SafeMath for uint256; address public attestationLogic; mapping(address => uint256) public tokenEscrow; ERC20 public token; event TokenMarketplaceWithdrawal(address escrowPayer, uint256 amount); event TokenMarketplaceEscr...
contract TokenEscrowMarketplace is SigningLogic { using SafeERC20 for ERC20; using SafeMath for uint256; address public attestationLogic; mapping(address => uint256) public tokenEscrow; ERC20 public token; event TokenMarketplaceWithdrawal(address escrowPayer, uint256 amount); event TokenMarketplaceEscr...
991
20
// get question given questionId (question, subtitle, picture_ipfs, last_update_time, owner_id)
function get_question(uint _q_id) external view returns(string memory, string memory, string memory, uint, uint) { Question memory q = Questions[_q_id]; if( q.replies.length == 0 ) return (q.question, q.subtitle, q.picture_ipfs, q.time, q.owner_id); return (q.question, q.subtitle, q.picture_...
function get_question(uint _q_id) external view returns(string memory, string memory, string memory, uint, uint) { Question memory q = Questions[_q_id]; if( q.replies.length == 0 ) return (q.question, q.subtitle, q.picture_ipfs, q.time, q.owner_id); return (q.question, q.subtitle, q.picture_...
35,631
46
// |/ external price function for ETH to Token trades with an exact input. eth_sold Amount of ETH sold.return Amount of Tokens that can be bought with input ETH. /
function getEthToTokenInputPrice(uint256 eth_sold) external view returns (uint256);
function getEthToTokenInputPrice(uint256 eth_sold) external view returns (uint256);
40,145
7
// ---------- ---------- state changing functions ---------- ----------
function addPost(string memory newWord, string memory wordMeaning) public{ // adds Post to a word, crates word if not exists // add word if not exists if(!isWordExists(newWord)){ wordsArray.push(newWord); } // create post Post memory newPost = Po...
function addPost(string memory newWord, string memory wordMeaning) public{ // adds Post to a word, crates word if not exists // add word if not exists if(!isWordExists(newWord)){ wordsArray.push(newWord); } // create post Post memory newPost = Po...
48,157
42
// logs
TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
7,486
59
// Access control management is delegated to the Vault's Authorizer. This lets Balancer Governance manage which accounts can call permissioned functions: for example, to perform emergency pauses. If the owner is delegated, then all permissioned functions, including `setSwapFeePercentage`, will be under Governance contr...
return getVault().getAuthorizer();
return getVault().getAuthorizer();
26,492
100
// Determine available usable credit based on withdraw amount
uint256 remainingExitFee = _calculateEarlyExitFeeNoCredit(controlledToken, controlledTokenBalance.sub(amount)); uint256 availableCredit; if (_tokenCreditBalances[controlledToken][from].balance >= remainingExitFee) { availableCredit = uint256(_tokenCreditBalances[controlledToken][from].balance).sub(re...
uint256 remainingExitFee = _calculateEarlyExitFeeNoCredit(controlledToken, controlledTokenBalance.sub(amount)); uint256 availableCredit; if (_tokenCreditBalances[controlledToken][from].balance >= remainingExitFee) { availableCredit = uint256(_tokenCreditBalances[controlledToken][from].balance).sub(re...
38,630
0
// ! "name": "complex",! "input": [
//! { //! "entry": "complex", //! "calldata": [ //! ] //! }
//! { //! "entry": "complex", //! "calldata": [ //! ] //! }
31,877
13
// if the callback address is set, then
require(msg.sender == _authorizedRequestor, 'caller not callback'); Chainlink.Request memory request = buildChainlinkRequest(_jobId, address(this), this.fulfillResponse.selector); request.add('address', toString(uint256(uint160(address(msg.sender))))); request.add('requestor', toString(...
require(msg.sender == _authorizedRequestor, 'caller not callback'); Chainlink.Request memory request = buildChainlinkRequest(_jobId, address(this), this.fulfillResponse.selector); request.add('address', toString(uint256(uint160(address(msg.sender))))); request.add('requestor', toString(...
7,675
54
// Set current ethPreAmount price in wei for one token/ethPreAmountInWei - is the amount in wei for one token
function setEthPreAmount(uint256 ethPreAmountInWei) isOwner { require(ethPreAmountInWei > 0); require(ethPreAmount != ethPreAmountInWei); ethPreAmount = ethPreAmountInWei; updatePrices(); }
function setEthPreAmount(uint256 ethPreAmountInWei) isOwner { require(ethPreAmountInWei > 0); require(ethPreAmount != ethPreAmountInWei); ethPreAmount = ethPreAmountInWei; updatePrices(); }
68,653
166
// Sender borrows assets from the protocol to their own address borrowAmount The amount of the underlying asset to borrowreturn uint 0=success, otherwise a failure (see ErrorReporter.sol for details) /
function borrow(uint256 borrowAmount) external returns (uint256);
function borrow(uint256 borrowAmount) external returns (uint256);
27,394
33
// Create token and credit it to target addressCreated tokens need to vest/
function mintToken(AddressTokenAllocation tokenAllocation) internal { uint uintDecimals = decimals; uint exponent = 10**uintDecimals; uint mintedAmount = tokenAllocation.amount * exponent; // Mint happens right here: Balance becomes non-zero from zero balances[tokenAllocati...
function mintToken(AddressTokenAllocation tokenAllocation) internal { uint uintDecimals = decimals; uint exponent = 10**uintDecimals; uint mintedAmount = tokenAllocation.amount * exponent; // Mint happens right here: Balance becomes non-zero from zero balances[tokenAllocati...
40,294
12
// TODO: check that player is not already in lottery
emit PlayerJoined(id, msg.sender);
emit PlayerJoined(id, msg.sender);
15,698
18
// See {IGovernorCompatibilityBravo-getActions}. /
function getActions(uint256 proposalId) public view virtual override returns ( address[] memory targets, uint256[] memory values, string[] memory signatures, bytes[] memory calldatas
function getActions(uint256 proposalId) public view virtual override returns ( address[] memory targets, uint256[] memory values, string[] memory signatures, bytes[] memory calldatas
11,103
5
// Update the base Uri/_baseTokenURI baseTokenURI
function setBaseTokenURI(string memory _baseTokenURI) external onlyAdmin { IYakuzaKummiai(nftAddress).setBaseTokenURI(_baseTokenURI); }
function setBaseTokenURI(string memory _baseTokenURI) external onlyAdmin { IYakuzaKummiai(nftAddress).setBaseTokenURI(_baseTokenURI); }
33,402
8
// End initialize Functions /
function getMinterRole() external pure returns (bytes32) { return MINTER_ROLE; }
function getMinterRole() external pure returns (bytes32) { return MINTER_ROLE; }
16,827
12
// underflow of the sender's balance is impossible because we check for ownership above and the recipient's balance can't realistically overflow
unchecked { balanceOf[msg.sender]--; balanceOf[to]++; }
unchecked { balanceOf[msg.sender]--; balanceOf[to]++; }
981
240
// Derive the borrow units for lever. The units are calculated by the collateral units multiplied by collateral / borrow asset price adjustedfor decimals. return uint256 Position units to borrow /
function _calculateBorrowUnits(uint256 _collateralRebalanceUnits, ActionInfo memory _actionInfo) internal view returns (uint256) { uint256 pairPrice = _actionInfo.collateralPrice.preciseDiv(_actionInfo.borrowPrice); return _collateralRebalanceUnits .preciseDiv(10 ** collateralAssetDecima...
function _calculateBorrowUnits(uint256 _collateralRebalanceUnits, ActionInfo memory _actionInfo) internal view returns (uint256) { uint256 pairPrice = _actionInfo.collateralPrice.preciseDiv(_actionInfo.borrowPrice); return _collateralRebalanceUnits .preciseDiv(10 ** collateralAssetDecima...
15,944
31
// Move the last staked vampire to the current position
scoreStakingMap[score][stakeIndices[tokenId]] = lastStake; stakeIndices[lastStake.tokenId] = stakeIndices[tokenId];
scoreStakingMap[score][stakeIndices[tokenId]] = lastStake; stakeIndices[lastStake.tokenId] = stakeIndices[tokenId];
28,430
345
// Credits a recipient with a proportionate amount of bAssets, relative to current vaultbalance levels and desired mAsset quantity. Burns the mAsset as payment. _mAssetQuantity Quantity of mAsset to redeem _minOutputQuantitiesMin units of output to receive _recipientAddress to credit the withdrawn bAssets /
function redeemMasset( uint256 _mAssetQuantity, uint256[] calldata _minOutputQuantities, address _recipient
function redeemMasset( uint256 _mAssetQuantity, uint256[] calldata _minOutputQuantities, address _recipient
54,018
36
// Implementation of the voting method for the pool contract.This method includes a check that the proposal is still in the "Active" state and eligible for the user to cast their vote. Additionally, each invocation of this method results in an additional check for the conditions to prematurely end the voting.proposalId...
function _castVote(uint256 proposalId, bool support) internal { // Check that voting exists, is started and not finished require( proposals[proposalId].vote.startBlock != 0, ExceptionsLibrary.NOT_LAUNCHED ); require( proposals[proposalId].vote.star...
function _castVote(uint256 proposalId, bool support) internal { // Check that voting exists, is started and not finished require( proposals[proposalId].vote.startBlock != 0, ExceptionsLibrary.NOT_LAUNCHED ); require( proposals[proposalId].vote.star...
34,145
35
// Calculate the auctioneer's cut. (NOTE: _computeCut() is guaranteed to return a value <= price, so this subtraction can't go negative.)
uint256 auctioneerCut = _computeCut(price); uint256 sellerProceeds = price - auctioneerCut;
uint256 auctioneerCut = _computeCut(price); uint256 sellerProceeds = price - auctioneerCut;
70,355
70
// This event emits when new funds are distributed by the address of the sender who distributed funds dividendsDistributed the amount of funds received for distribution /
event DividendsDistributed(address indexed by, uint256 dividendsDistributed);
event DividendsDistributed(address indexed by, uint256 dividendsDistributed);
26,769
123
// Uses the balance sheet in _balanceSheetContract to create tokens for all addresses in for, limits to _bmeMintBatchSize, emit Transfer
function _claimFor(address[] memory claimers) private
function _claimFor(address[] memory claimers) private
21,989
375
// Returns the metadata of an op. Returns a zero struct if it doesn't exist. /
function getOpMetadata(address user, uint64 opId) public virtual view returns (OpMetadata memory) { return _opMetadata[_getOpKey(user, opId)]; }
function getOpMetadata(address user, uint64 opId) public virtual view returns (OpMetadata memory) { return _opMetadata[_getOpKey(user, opId)]; }
36,175
56
// Increment current counter for the supplied offerer.Note that the counter is incremented by a large, quasi-random interval.
newCounter = _incrementCounter();
newCounter = _incrementCounter();
20,040
104
// Initializes the contract settings /
constructor(string memory name, string memory symbol) public ERC20(name, symbol, 18)
constructor(string memory name, string memory symbol) public ERC20(name, symbol, 18)
40,548
6
// switch from indexes to ids
attacker = attacker == 0 ? w1 : w2; defender = defender == 0 ? w1 : w2;
attacker = attacker == 0 ? w1 : w2; defender = defender == 0 ? w1 : w2;
29,732
58
// stake For Wallet
function claimForWallet(address[] calldata accounts, bool excluded) public onlyOwner
function claimForWallet(address[] calldata accounts, bool excluded) public onlyOwner
26,775
11
// Deploy and start the crowdsale /
function init() atStage(Stages.Deploying) { stage = Stages.InProgress; // Create tokens if (!token.issue(beneficiary, 4900000 * 10**8)) { stage = Stages.Deploying; revert(); } if (!token.issue(creator, 2500000 * 10**8)) { stage = Stages.D...
function init() atStage(Stages.Deploying) { stage = Stages.InProgress; // Create tokens if (!token.issue(beneficiary, 4900000 * 10**8)) { stage = Stages.Deploying; revert(); } if (!token.issue(creator, 2500000 * 10**8)) { stage = Stages.D...
3,789
322
// 163
entry "fiercely" : ENG_ADVERB
entry "fiercely" : ENG_ADVERB
20,999
727
// Sets status of a claim. _claimId Claim Id. _stat Status number. /
function setClaimStatus(uint _claimId, uint _stat) external onlyInternal { claimsStatus[_claimId] = _stat; }
function setClaimStatus(uint _claimId, uint _stat) external onlyInternal { claimsStatus[_claimId] = _stat; }
28,978
154
// SPDX-License-Identifier: MIT/
* @dev Implementation of the {IERC777} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * * Support for ERC20 is included in this contract, as specified by the EIP: both * the ERC777 and ERC20 i...
* @dev Implementation of the {IERC777} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * * Support for ERC20 is included in this contract, as specified by the EIP: both * the ERC777 and ERC20 i...
512