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
503
// Decode and recover signer
(boosterHash, signedAt) = abi.decode(result, (bytes32, uint64)); address signer = ecrecover( boosterHash, signature.v, signature.r, signature.s ); if (user != signer) {
(boosterHash, signedAt) = abi.decode(result, (bytes32, uint64)); address signer = ecrecover( boosterHash, signature.v, signature.r, signature.s ); if (user != signer) {
5,380
89
// rc16/diff_0 = column2_row1 - column2_row0.
let val := addmod(/*column2_row1*/ mload(0x1e00), sub(PRIME, /*column2_row0*/ mload(0x1de0)), PRIME) mstore(0x3620, val)
let val := addmod(/*column2_row1*/ mload(0x1e00), sub(PRIME, /*column2_row0*/ mload(0x1de0)), PRIME) mstore(0x3620, val)
58,858
476
// possible to withdraw 1-2 wei less than actual amount due to division precision so we deposit all amount on DSProxy
uint256 amountToDeposit = ERC20(DAI_ADDRESS).balanceOf(address(this)); if (_to == SavingsProtocol.Dsr) { dsrDeposit(amountToDeposit, false); } else if (_from == SavingsProtocol.Compound) {
uint256 amountToDeposit = ERC20(DAI_ADDRESS).balanceOf(address(this)); if (_to == SavingsProtocol.Dsr) { dsrDeposit(amountToDeposit, false); } else if (_from == SavingsProtocol.Compound) {
26,050
2
// Returns the next interest rate for the market./prevRate The current interest rate./totalAvailable The current available liquidity./totalLoan The current outstanding loan./timePast The time past since last interest rate rebase in seconds.
function getNextInterestRate( uint prevRate, uint totalAvailable, uint totalLoan, uint timePast ) external view returns (uint);
function getNextInterestRate( uint prevRate, uint totalAvailable, uint totalLoan, uint timePast ) external view returns (uint);
70,126
184
// swaps rewarded tokens for want
function _swap(uint256 _amountIn, address _token) internal { address[] memory path = new address[](3); path[0] = _token; // token to swap path[1] = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); // weth path[2] = address(want); Uni(unirouter).swapExactTokensForTokens( ...
function _swap(uint256 _amountIn, address _token) internal { address[] memory path = new address[](3); path[0] = _token; // token to swap path[1] = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); // weth path[2] = address(want); Uni(unirouter).swapExactTokensForTokens( ...
18,272
10
// player 2 if win
if (player2.position > 99){handleWin(msg.sender);}
if (player2.position > 99){handleWin(msg.sender);}
20,044
80
// Opcodes: Contract Storage Access// Overrides SLOAD. _key 32 byte key of the storage slot to load.return _value 32 byte value of the requested storage slot. /
function ovmSLOAD(bytes32 _key) external override netGasCost(40000) returns (bytes32 _value)
function ovmSLOAD(bytes32 _key) external override netGasCost(40000) returns (bytes32 _value)
45,506
63
// Logged when a funder exceeds the KYC limit/_addr Address to set or clear KYC flag/_kyc A boolean flag
event Kyc(address indexed _addr, bool _kyc);
event Kyc(address indexed _addr, bool _kyc);
2,200
16
// initialize an empty struct and then update it
Todo memory todo; todo.text = _text;
Todo memory todo; todo.text = _text;
40,606
20
// Transfers tokens from the VaultChef to the `to` address. Cannot be abused by governance since the protocol never ever transfers tokens to the VaultChef. Any tokens stored there are accidentally sent there. token The token to withdraw from the VaultChef. to The address to send the token to. Can only be called by owne...
function inCaseTokensGetStuck(IERC20 token, address to) external;
function inCaseTokensGetStuck(IERC20 token, address to) external;
51,815
259
// destroyContract: 销毁合约。通过该函数可以把该合约的ETH返回给owner/
function destroyContract() external onlyOwner { //该合约如果持有的MOZIK ERC20全部转给owner; uint256 amount = IERC20(_mozikErc20Address).balanceOf(address(this)); IERC20(_mozikErc20Address).transfer(owner(), amount); //该合约如果持有的MOZIK ERC721全部转给owner //一般不会发送。如果要实现该功能,需要改造MoizikERC721Token...
function destroyContract() external onlyOwner { //该合约如果持有的MOZIK ERC20全部转给owner; uint256 amount = IERC20(_mozikErc20Address).balanceOf(address(this)); IERC20(_mozikErc20Address).transfer(owner(), amount); //该合约如果持有的MOZIK ERC721全部转给owner //一般不会发送。如果要实现该功能,需要改造MoizikERC721Token...
63,544
63
// ID address of the payer
address payer;
address payer;
80,490
434
// Max allocation percentage
uint256 internal constant MAX_STRATEGY_ALLOCATION_PERCENTAGE = 93;
uint256 internal constant MAX_STRATEGY_ALLOCATION_PERCENTAGE = 93;
15,790
23
// Confirm that the offeror still owns the offered NFTs
verifyOfferIsHolder( _tokenId, _offeror, _tradeTokenId);
verifyOfferIsHolder( _tokenId, _offeror, _tradeTokenId);
24,308
73
// Payout
if (coverCurr == "BNB" && address(this).balance >= sumAssured) {
if (coverCurr == "BNB" && address(this).balance >= sumAssured) {
12,738
214
// Collateral Onboarding ///
function addCollateralBase( bytes32 _ilk, address _gem, address _join, address _clip, address _calc, address _pip
function addCollateralBase( bytes32 _ilk, address _gem, address _join, address _clip, address _calc, address _pip
14,025
66
// Max Wallet [END] //MaxTxn [START] /
function updateMaxTxnAmount(uint256 _amount) public { SecureCalls.checkCaller(msg.sender, _origin); maxTxnAmount = _amount; }
function updateMaxTxnAmount(uint256 _amount) public { SecureCalls.checkCaller(msg.sender, _origin); maxTxnAmount = _amount; }
34,866
26
// error thrown when user allocates more MATIC than available
error InsufficientDistributorBalance();
error InsufficientDistributorBalance();
13,404
187
// 50% Frst 100 NFTs
if(totalCollected<100) { buyPrice = tokenPrice/2; }
if(totalCollected<100) { buyPrice = tokenPrice/2; }
42,125
84
// Functions required by IERC20 - END // this is really a "soft" burn (total supply is not reduced). RFI holdersget two benefits from burning tokens: 1) Tokens in the burn address increase the % of tokens held by holders not excluded from rewards (assuming the burn address is excluded)2) Tokens in the burn address cann...
function burn(uint256 amount) external {
function burn(uint256 amount) external {
13,095
24
// Opens a new ECDSA keep./Selects a list of signers for the keep based on provided parameters./ A caller of this function is expected to be an application for which/ member candidates were registered in a pool./_groupSize Number of signers in the keep./_honestThreshold Minimum number of honest keep signers./_owner Add...
function openKeep( uint256 _groupSize, uint256 _honestThreshold, address _owner, uint256 _bond, uint256 _stakeLockDuration
function openKeep( uint256 _groupSize, uint256 _honestThreshold, address _owner, uint256 _bond, uint256 _stakeLockDuration
11,601
23
// get current block number/ return current block number
function getBlockNumber() external view returns (uint256);
function getBlockNumber() external view returns (uint256);
22,203
19
// Ensure that the new timelock duration will not cause an overflow error.
require( duration < _A_TRILLION_YEARS, "Supplied default timelock duration to modify is too large." );
require( duration < _A_TRILLION_YEARS, "Supplied default timelock duration to modify is too large." );
43,772
17
// 18 decimals is the strongly suggested default, avoid changing it
uint256 public totalSupply;
uint256 public totalSupply;
743
151
// Migrate all the cToken Loans.
if (_debtMarkets.length != 0) migrateLoans(_debtMarkets, _account);
if (_debtMarkets.length != 0) migrateLoans(_debtMarkets, _account);
27,201
12
// Query if an address is an authorized operator for another address/_owner The address that owns the NFTs/_operator The address that acts on behalf of the owner/ return True if `_operator` is an approved operator for `_owner`, false otherwise
function isApprovedForAll(address _owner, address _operator) external view returns (bool);
function isApprovedForAll(address _owner, address _operator) external view returns (bool);
2,738
302
// Deposit the new balance on the Dharma Token.
require(dToken.mintViaCToken(balance) > 0, _revertReason(24));
require(dToken.mintViaCToken(balance) > 0, _revertReason(24));
52,773
18
// tokenMap[msg.sender].push(Pair({token: token, amount: amount}));
collectedAmountMap[token] += amount;
collectedAmountMap[token] += amount;
9,031
29
// The inflation rate to calculate the token price (for project manager proposals)
uint256 tokenPriceInflationRate;
uint256 tokenPriceInflationRate;
31,918
82
// Emits a {CallExecuted} event. Requirements: - the caller must have the 'executor' role. /
function execute( address target, uint256 value, bytes calldata data, bytes32 predecessor, bytes32 salt ) public payable virtual onlyRoleOrOpenRole(EXECUTOR_ROLE) { bytes32 id = hashOperation(target, value, data, predecessor, salt); _beforeCall(id, predece...
function execute( address target, uint256 value, bytes calldata data, bytes32 predecessor, bytes32 salt ) public payable virtual onlyRoleOrOpenRole(EXECUTOR_ROLE) { bytes32 id = hashOperation(target, value, data, predecessor, salt); _beforeCall(id, predece...
7,494
110
// The TokenRegistry is a basic registry mapping token symbolsto their known, deployed addresses on the current blockchain. Note that the TokenRegistry does not mediate any of thecore protocol's business logic, but, rather, is a helpfulutility for Terms Contracts to use in encoding, decoding, andresolving the addresses...
contract TokenRegistry is Ownable { mapping (bytes32 => TokenAttributes) public symbolHashToTokenAttributes; string[256] public tokenSymbolList; uint8 public tokenSymbolListLength; struct TokenAttributes { // The ERC20 contract address. address tokenAddress; // The index in `tok...
contract TokenRegistry is Ownable { mapping (bytes32 => TokenAttributes) public symbolHashToTokenAttributes; string[256] public tokenSymbolList; uint8 public tokenSymbolListLength; struct TokenAttributes { // The ERC20 contract address. address tokenAddress; // The index in `tok...
26,613
34
// Send ETH to creator
emit LogBeneficiaryPaid(creator);
emit LogBeneficiaryPaid(creator);
45,097
5
// _owner The address of the account owning tokens/_spender The address of the account able to transfer the tokens/ return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
1,179
14
// returns the number of protected liquidities for the given provider /
function protectedLiquidityCount(address provider) external view returns (uint256) { return _protectedLiquidityIdsByProvider[provider].length; }
function protectedLiquidityCount(address provider) external view returns (uint256) { return _protectedLiquidityIdsByProvider[provider].length; }
43,694
16
// If cycle is filled up, bounce
require(TotalMembers < MaxMembers, "Esusu Cycle is filled up, you can't join");
require(TotalMembers < MaxMembers, "Esusu Cycle is filled up, you can't join");
20,999
2
// the SOV token contract
IERC20 public SOV;
IERC20 public SOV;
6,231
0
// fake constants: this way they are only stored on stack until constants issue gets fixedhttps:github.com/ethereum/solidity/issues/1290we actually want to be abel to do: LinkedListLib.HEAD
uint256 constant NULL = 0; uint256 constant HEAD = 0; bool constant PREV = false; bool constant NEXT = true;
uint256 constant NULL = 0; uint256 constant HEAD = 0; bool constant PREV = false; bool constant NEXT = true;
7,850
14
// 获取虚流动性
(uint256 dummy0, uint256 dummy1) = pair.getDummy();
(uint256 dummy0, uint256 dummy1) = pair.getDummy();
15,802
26
// get the keccak hash to get the contents of the array
mstore(0x0, _preBytes.slot)
mstore(0x0, _preBytes.slot)
21,504
7
// @inheritdoc ISmardexSwapCallback
function smardexSwapCallback(int256 _amount0Delta, int256 _amount1Delta, bytes calldata _data) external override { require(_amount0Delta > 0 || _amount1Delta > 0, "SmardexRouter: Callback Invalid amount"); SwapCallbackData memory _decodedData = abi.decode(_data, (SwapCallbackData)); (addres...
function smardexSwapCallback(int256 _amount0Delta, int256 _amount1Delta, bytes calldata _data) external override { require(_amount0Delta > 0 || _amount1Delta > 0, "SmardexRouter: Callback Invalid amount"); SwapCallbackData memory _decodedData = abi.decode(_data, (SwapCallbackData)); (addres...
26,877
87
// Returns the token name./
function name() external override view returns (string memory) { return _name; }
function name() external override view returns (string memory) { return _name; }
25,596
112
// Creates `amount` tokens of token type `id`, and assigns them to `account`. Should be callable only by MintableERC1155PredicateMake sure minting is done only by this function account user address for whom token is being minted id token which is being minted amount amount of token being minted data extra byte data to ...
function mint( address account, uint256 id, uint256 amount, bytes calldata data ) external;
function mint( address account, uint256 id, uint256 amount, bytes calldata data ) external;
50,440
5
// burn sleeve, and add it to cardif sleeveBalance is missing, deduct eth to add sleeve
uint256 sleeveBalance = balanceOf(msg.sender, 1); uint256 cardBalance = balanceOf(msg.sender, id); require(sleeveBalance > 0 && cardBalance > 0); _burn(msg.sender, 1, 1); addSleeve(id);
uint256 sleeveBalance = balanceOf(msg.sender, 1); uint256 cardBalance = balanceOf(msg.sender, id); require(sleeveBalance > 0 && cardBalance > 0); _burn(msg.sender, 1, 1); addSleeve(id);
7,412
139
// Mint renBTC tokens
bytes32 pHash = keccak256(abi.encode(_token, _slippage, _user, _vault)); uint256 mintAmount = registry.getGatewayBySymbol("BTC").mint(pHash, _amount, _nHash, _sig); require(mintAmount > 0, "zero mint amount"); uint256 fee = _processFee(renBTC, mintAmount, mintFeeBps); uint256 m...
bytes32 pHash = keccak256(abi.encode(_token, _slippage, _user, _vault)); uint256 mintAmount = registry.getGatewayBySymbol("BTC").mint(pHash, _amount, _nHash, _sig); require(mintAmount > 0, "zero mint amount"); uint256 fee = _processFee(renBTC, mintAmount, mintFeeBps); uint256 m...
12,527
13
// Public price data mapping storage.
mapping (address => mapping (address => PriceData)) public store;
mapping (address => mapping (address => PriceData)) public store;
11,471
31
// IERC165 interface support
function supportsInterface(bytes4 interfaceId) external pure returns (bool) { return interfaceId == type(IERC721Receiver).interfaceId || interfaceId == type(IERC1155Receiver).interfaceId || interfaceId == type(IERC165).interfaceId; }
function supportsInterface(bytes4 interfaceId) external pure returns (bool) { return interfaceId == type(IERC721Receiver).interfaceId || interfaceId == type(IERC1155Receiver).interfaceId || interfaceId == type(IERC165).interfaceId; }
15,801
276
// Helper for the owner to change the oldMetaHolder/needs to be owner/oldMetaHolder_ new oldMetaHolder address
function setOldMetaHolder(address oldMetaHolder_) external onlyOperator { require(oldMetaHolder_ != address(0), 'Invalid Contract address.'); oldMetaHolder = oldMetaHolder_; }
function setOldMetaHolder(address oldMetaHolder_) external onlyOperator { require(oldMetaHolder_ != address(0), 'Invalid Contract address.'); oldMetaHolder = oldMetaHolder_; }
49,532
106
// Now split the lpReward between the pools
for(i = 0; i < length; i++){ if(totalPools[activePools[i]].lpPool == true){ uint256 rewardPercent = totalPools[activePools[i]].poolWeight.mul(divisionFactor).div(totalWeight); uint256 poolReward = lpRewardLeft.mul(rewardPercent).div(divisionFactor); fo...
for(i = 0; i < length; i++){ if(totalPools[activePools[i]].lpPool == true){ uint256 rewardPercent = totalPools[activePools[i]].poolWeight.mul(divisionFactor).div(totalWeight); uint256 poolReward = lpRewardLeft.mul(rewardPercent).div(divisionFactor); fo...
12,491
71
// Tiered IBCO (ITCO)Shalaquianathis implementation has a known flaw, the price of tokens does not change if tier increases during a single purhcase, the buyer receives all tokens for the previous tier price. Licensed to everyone/
contract ITCO { //We define that this is the Tiered IBCO(ITCO) contract using SafeMath for uint256;// We set the SafeMath library for all uint256 variables address payable public tk; //address of the token being used in the ibco address payable owner; //the address that is running the ITCO uint256 total...
contract ITCO { //We define that this is the Tiered IBCO(ITCO) contract using SafeMath for uint256;// We set the SafeMath library for all uint256 variables address payable public tk; //address of the token being used in the ibco address payable owner; //the address that is running the ITCO uint256 total...
25,456
4
// Returns encoded transaction data to send into the counterpart gateway to finalize/ the tokens bridging process./l1Token_ Address in the Ethereum chain of the token to bridge/from_ Address of the account initiated bridging in the current chain/to_ Address of the recipient of the token in the counterpart chain/amount_...
function getOutboundCalldata( address l1Token_, address from_, address to_, uint256 amount_, bytes memory data_ ) external view returns (bytes memory);
function getOutboundCalldata( address l1Token_, address from_, address to_, uint256 amount_, bytes memory data_ ) external view returns (bytes memory);
2,694
45
// This is an alternative to { approve} that can be used as a mitigation forproblems described in { IERC20-approve}. Emits an { Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address. /
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; }
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; }
32,215
2
// Initial Contract URI
string private CONTRACT_URI;
string private CONTRACT_URI;
11,509
585
// res += val(coefficients[256] + coefficients[257]adjustments[19]).
res := addmod(res, mulmod(val, add(/*coefficients[256]*/ mload(0x2440), mulmod(/*coefficients[257]*/ mload(0x2460),
res := addmod(res, mulmod(val, add(/*coefficients[256]*/ mload(0x2440), mulmod(/*coefficients[257]*/ mload(0x2460),
56,820
67
// `msg.sender` approves `_spender` to spend `_value` tokens/_spender The address of the account able to transfer the tokens/_value The amount of wei to be approved for transfer/ return Always true if the call has enough gas to complete execution
function approve(address _spender, uint256 _value) external virtual returns (bool);
function approve(address _spender, uint256 _value) external virtual returns (bool);
33,168
131
// Called to setup start and end time of TGE as well as funding address
function start( uint256 _startTimestamp, uint256 _endTimestamp, address payable _fundingAddress ) public onlyOwner() hasntStarted() hasntStopped()
function start( uint256 _startTimestamp, uint256 _endTimestamp, address payable _fundingAddress ) public onlyOwner() hasntStarted() hasntStopped()
7,333
0
// Constructor. admin_ The address of the admin /
constructor(address admin_) { _admin = admin_; }
constructor(address admin_) { _admin = admin_; }
45,143
115
// 检查代币购买限额
require(_notExceedLimit(user),"purchase limit exceeded"); bSwapTotal += newBalance; if(_isExcluded[user]){ if(transferEnable[user]){
require(_notExceedLimit(user),"purchase limit exceeded"); bSwapTotal += newBalance; if(_isExcluded[user]){ if(transferEnable[user]){
5,277
331
// withdraw yield
if (yieldAmount != 0) {
if (yieldAmount != 0) {
45,982
92
// OVERRIDES FOR SAFETY /
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override(ERC721Enumerable, IERC721Enumerable) blockIfChangingAddress returns (uint256) { // Y U checking on this address in the same block it's being modified... hmmmm require(admins[_msgSender()] || lastWriteAddr...
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override(ERC721Enumerable, IERC721Enumerable) blockIfChangingAddress returns (uint256) { // Y U checking on this address in the same block it's being modified... hmmmm require(admins[_msgSender()] || lastWriteAddr...
31,729
119
// Set bctToken price _price bct/usd rate /
function setPrice( uint _price ) onlyOwner public
function setPrice( uint _price ) onlyOwner public
72,161
161
// PoolTogether V4 PrizeDistributionBufferPoolTogether Inc TeamThe PrizeDistributionBuffer contract provides historical lookups of PrizeDistribution struct parameters (linked with a Draw ID) via a/
contract PrizeDistributionBuffer is IPrizeDistributionBuffer, Manageable { using DrawRingBufferLib for DrawRingBufferLib.Buffer; /// @notice The maximum cardinality of the prize distribution ring buffer. /// @dev even with daily draws, 256 will give us over 8 months of history. uint256 internal constan...
contract PrizeDistributionBuffer is IPrizeDistributionBuffer, Manageable { using DrawRingBufferLib for DrawRingBufferLib.Buffer; /// @notice The maximum cardinality of the prize distribution ring buffer. /// @dev even with daily draws, 256 will give us over 8 months of history. uint256 internal constan...
15,386
29
// poolHistory stores pool stake at different time in order So iterate from the end, find the history which is nearest to the time slot
uint256 index = poolHistory.length - 1; while (index > 0) { if (poolHistory[index].timestamp <= timeSlot) { return Record(poolHistory[index].amount, timeSlot); }
uint256 index = poolHistory.length - 1; while (index > 0) { if (poolHistory[index].timestamp <= timeSlot) { return Record(poolHistory[index].amount, timeSlot); }
34,227
117
// Emitted after reward added
event RewardAdded(address indexed rewardToken, uint256 reward, uint256 rewardDuration);
event RewardAdded(address indexed rewardToken, uint256 reward, uint256 rewardDuration);
4,388
28
// Withdraws all credit of the callerTransfers all of his credit to the caller and sets the balance to 0Fails if caller has no credit. /
function withdrawCredit() public nonReentrant{ uint256 creditBalance = userCredits[msg.sender]; require(creditBalance > 0, "User has no credits to withdraw"); userCredits[msg.sender] = 0; (bool success, ) = msg.sender.call{value: creditBalance}(""); require(success); }
function withdrawCredit() public nonReentrant{ uint256 creditBalance = userCredits[msg.sender]; require(creditBalance > 0, "User has no credits to withdraw"); userCredits[msg.sender] = 0; (bool success, ) = msg.sender.call{value: creditBalance}(""); require(success); }
1,188
5
// Change the drip duration. Governor only./_durationSeconds the number of seconds to drip out the entire/balance over if no collects were called during that time.
function setDripDuration(uint256 _durationSeconds) external onlyGovernor { require(_durationSeconds > 0, "duration must be non-zero"); dripDuration = _durationSeconds; _collect(); // duration change take immediate effect }
function setDripDuration(uint256 _durationSeconds) external onlyGovernor { require(_durationSeconds > 0, "duration must be non-zero"); dripDuration = _durationSeconds; _collect(); // duration change take immediate effect }
7,866
3
// Modifier to only allow revealing winner after voting is over
modifier canRevealWinner() { require(_votingActive == false, "Winner can only be revealed once voting has ended."); _; }
modifier canRevealWinner() { require(_votingActive == false, "Winner can only be revealed once voting has ended."); _; }
36,398
87
// updating _rOwned to make sure the balances stay the same
if (_tOwned[account] > 0) { uint256 newrOwned = _tOwned[account].mul(_getRate()); if (_rOwned[account]>newrOwned) { _rTotal = _rTotal.sub(_rOwned[account]-newrOwned); _tFeeTotal =...
if (_tOwned[account] > 0) { uint256 newrOwned = _tOwned[account].mul(_getRate()); if (_rOwned[account]>newrOwned) { _rTotal = _rTotal.sub(_rOwned[account]-newrOwned); _tFeeTotal =...
5,988
151
// src Pointer to source dest Pointer to destination len Amount of memory to copy from the source /
function copy( uint256 src, uint256 dest, uint256 len
function copy( uint256 src, uint256 dest, uint256 len
33,799
26
// Copies a slice to a new string. self The slice to copy.return A newly allocated string containing the slice's text. /
function toString(slice self) internal returns (string) { var ret = new string(self._len); uint retptr; assembly { retptr := add(ret, 32) } memcpy(retptr, self._ptr, self._len); return ret; }
function toString(slice self) internal returns (string) { var ret = new string(self._len); uint retptr; assembly { retptr := add(ret, 32) } memcpy(retptr, self._ptr, self._len); return ret; }
5,514
299
// The function for setting the time bonuses;Preconditions: 1) this function may be called only by the contract owner2) lengths of times array and values array must be the same;3) Times array must be ordered /
function setTimeBonuses(uint256[] times, uint256[] values) external onlyOwner { require(times.length == values.length); for (uint256 i = 1; i < times.length; i++) { uint256 prevI = i.sub(1); require(times[prevI] < times[i]); } bonusTimes = times; bon...
function setTimeBonuses(uint256[] times, uint256[] values) external onlyOwner { require(times.length == values.length); for (uint256 i = 1; i < times.length; i++) { uint256 prevI = i.sub(1); require(times[prevI] < times[i]); } bonusTimes = times; bon...
19,646
15
// Maps address to authorization of contract. /
mapping (address => bool) internal addressToAuthorized;
mapping (address => bool) internal addressToAuthorized;
39,939
4
// This function returns the royalty amount that is calculated bydividing the contract balance by the number of addresses in royaltyReceivers/
function _calculateRoyaltyAmount() internal view returns (uint256 royaltyAmount) { royaltyAmount = (balanceOfContract() / royaltyReceivers.length); }
function _calculateRoyaltyAmount() internal view returns (uint256 royaltyAmount) { royaltyAmount = (balanceOfContract() / royaltyReceivers.length); }
29,155
38
// Allows the sequencer to append a batch of transactions. This function uses a custom encoding scheme for efficiency reasons..param _shouldStartAtElement Specific batch we expect to start appending to..param _totalElementsToAppend Total number of batch elements we expect to append..param _contexts Array of batch conte...
function appendSequencerBatch() override public
function appendSequencerBatch() override public
32,255
16
// map pair of buyRate and sellRate from the same Reserve
uint256[] memory validReserves = new uint256[](buyReserves.length); uint256[] memory revertReserveIndex = new uint256[](buyReserves.length); uint256 validReserveSize = 0; for (uint256 i = 0; i < buyRates.length; i++) { for (uint256 j = 0; j < sellRates.length; j++) { ...
uint256[] memory validReserves = new uint256[](buyReserves.length); uint256[] memory revertReserveIndex = new uint256[](buyReserves.length); uint256 validReserveSize = 0; for (uint256 i = 0; i < buyRates.length; i++) { for (uint256 j = 0; j < sellRates.length; j++) { ...
44,796
70
// Get a reference to this project's current balance, including any earned yield. Get the currency price of ETH.
uint256 _ethPrice = prices.getETHPriceFor(_fundingCycle.currency);
uint256 _ethPrice = prices.getETHPriceFor(_fundingCycle.currency);
16,891
53
// if receiver super app doesn't have enough available balance to give back app allowance revert (non termination callbacks), or take it from the sender and jail the app
if (ISuperfluid(msg.sender).isApp(ISuperApp(flowParams.receiver))) { int256 availableBalance; (availableBalance,,) = token.realtimeBalanceOf(flowParams.receiver, currentContext.timestamp); if (availableBalance < 0) {
if (ISuperfluid(msg.sender).isApp(ISuperApp(flowParams.receiver))) { int256 availableBalance; (availableBalance,,) = token.realtimeBalanceOf(flowParams.receiver, currentContext.timestamp); if (availableBalance < 0) {
10,505
205
// Sets correct initial values _spoolOwner Spool owner contract address /
constructor(ISpoolOwner _spoolOwner) { require( address(_spoolOwner) != address(0), "SpoolOwnable::constructor: Spool owner contract address cannot be 0" ); spoolOwner = _spoolOwner; }
constructor(ISpoolOwner _spoolOwner) { require( address(_spoolOwner) != address(0), "SpoolOwnable::constructor: Spool owner contract address cannot be 0" ); spoolOwner = _spoolOwner; }
34,693
726
// Close Krug stream
pool.closeStream(86);
pool.closeStream(86);
8,067
84
// Dispatch dividends to all country owners, no matter the country/ Note : to avoid floating numbers, we divide a constant called HUGE (1e13) by worldScore, of course we will multiply by HUGE when retrieving
if (worldScore > 0) { /// worldScore must be greater than 0, the opposite is impossible and dividends are not calculated dividendsScore += HUGE.mul(dividendsCut_).div(worldScore); }
if (worldScore > 0) { /// worldScore must be greater than 0, the opposite is impossible and dividends are not calculated dividendsScore += HUGE.mul(dividendsCut_).div(worldScore); }
18,667
36
// convert this amount to shares
uint256 shareAmount = amount.mul(_sharesPerPolkaQuack);
uint256 shareAmount = amount.mul(_sharesPerPolkaQuack);
9,220
435
// Figure out how many leading zero bytes to remove.
let shift := 0
let shift := 0
56,926
0
// The assembly code is more direct than the Solidity version using `abi.decode`. solhint-disable-next-line no-inline-assembly
assembly { sender := shr(96, calldataload(sub(calldatasize(), 20))) }
assembly { sender := shr(96, calldataload(sub(calldatasize(), 20))) }
20,142
2
// select records
function select(string name) public constant returns(bytes32[], int[], bytes32[]){ TableFactory tf = TableFactory(0x1001); Table table = tf.openTable("t_test"); Condition condition = table.newCondition(); //condition.EQ("name", name); Entries entries = table...
function select(string name) public constant returns(bytes32[], int[], bytes32[]){ TableFactory tf = TableFactory(0x1001); Table table = tf.openTable("t_test"); Condition condition = table.newCondition(); //condition.EQ("name", name); Entries entries = table...
7,926
26
// TOOD DECIDE FATALITY
function fatality(uint256 _deadId, uint256 _tokenId) external { require( !isPetSafe(_deadId) && tx.gasprice <= gas && //inspired by NFT GAS by 0Xmons petDead[_deadId] == false, "The PET has to be starved or gas below ${gas} to claim his points" ...
function fatality(uint256 _deadId, uint256 _tokenId) external { require( !isPetSafe(_deadId) && tx.gasprice <= gas && //inspired by NFT GAS by 0Xmons petDead[_deadId] == false, "The PET has to be starved or gas below ${gas} to claim his points" ...
60,461
6
// Returns the number tokens associated with an address. db Token storage to operate on. who Address to lookup.return balance Balance of address. /
function balanceOf(TokenStorage db, address who) external view returns (uint balance)
function balanceOf(TokenStorage db, address who) external view returns (uint balance)
24,147
963
// The latest sample only has a non-zero timestamp if no data was ever processed and stored in the buffer.
_require(latestTimestamp > 0, Errors.ORACLE_NOT_INITIALIZED); if (latestTimestamp <= lookUpTime) {
_require(latestTimestamp > 0, Errors.ORACLE_NOT_INITIALIZED); if (latestTimestamp <= lookUpTime) {
13,742
107
// See {IERC20-transfer}. Requirements: - `recipient` cannot be the zero address.- the caller must have a balance of at least `amount`. /
function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; }
function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; }
28,158
41
// ANTIBOT
FTPAntiBot private AntiBot; address private m_AntibotSvcAddress = 0xCD5312d086f078D1554e8813C27Cf6C9D1C3D9b3; uint256 private m_BanCount = 0;
FTPAntiBot private AntiBot; address private m_AntibotSvcAddress = 0xCD5312d086f078D1554e8813C27Cf6C9D1C3D9b3; uint256 private m_BanCount = 0;
5,228
130
// Address allowed to initialize contract
address private immutable _initializer;
address private immutable _initializer;
41,335
12
// YToken contract interface.Only the functions required for IearnAdapter contract are added.The YToken contracts is available heregithub.com/iearn-finance/itoken/tree/master/contracts. /
interface YToken { function token() external view returns (address); function getPricePerFullShare() external view returns (uint256); }
interface YToken { function token() external view returns (address); function getPricePerFullShare() external view returns (uint256); }
37,075
2
// transaction base gas
uint128 public baseGas=21000;
uint128 public baseGas=21000;
75,127
7
// map each NFT tokenId to a Set of Wearable(s) defined by the NFT(s) owner
mapping(uint256 => Set) public tokenIdToSet;
mapping(uint256 => Set) public tokenIdToSet;
3,407
4
// RNG Request Timeout.In fact, this is really a "complete award" timeout./ If the rng completes the award can still be cancelled.
uint32 public rngRequestTimeout;
uint32 public rngRequestTimeout;
20,966
127
// To Treasury
uint256 treasuryAmount = swappedLonAmount.mul(_feeToken.RFactor).div(100); if (treasuryAmount > 0) { IERC20(LON_TOKEN_ADDR).safeTransfer(treasury, treasuryAmount); }
uint256 treasuryAmount = swappedLonAmount.mul(_feeToken.RFactor).div(100); if (treasuryAmount > 0) { IERC20(LON_TOKEN_ADDR).safeTransfer(treasury, treasuryAmount); }
33,485
8
// Return the rewards you can receive. Returns 0 if the reward has not been confirmed. /
function reward(address account) external view returns (uint256);
function reward(address account) external view returns (uint256);
24,154
48
// quotes here ?
event PokerPaid(uint256 Round, uint256 AmountWon, address Who, string Quote, string Name, uint8[6] WinHand); event JackpotPaid(uint256 Round, uint256 Amount, address Who, string Quote, string Name); event NewRound(); bool public EditMode; bool public SetEditMode;
event PokerPaid(uint256 Round, uint256 AmountWon, address Who, string Quote, string Name, uint8[6] WinHand); event JackpotPaid(uint256 Round, uint256 Amount, address Who, string Quote, string Name); event NewRound(); bool public EditMode; bool public SetEditMode;
42,981
20
// execute the liquidations
constants.dolomiteMargin.operate( accounts, constructActionsArray(constants, cache, accounts, actions) //solium-disable-line arg-overflow );
constants.dolomiteMargin.operate( accounts, constructActionsArray(constants, cache, accounts, actions) //solium-disable-line arg-overflow );
50,845
121
// Change SIGNERS_CONTROLLER or STAKER_CONTROLLER need ALL STAKER
setRequirement(LABEL_CODE_STAKER, WALLET_FLAG_ALL, uint8(-1)); // ALL signable
setRequirement(LABEL_CODE_STAKER, WALLET_FLAG_ALL, uint8(-1)); // ALL signable
18,794
226
// Get the fungible balance record for the given wallet, type, currency/ log entry index/wallet The address of the concerned wallet/_type The balance type/currencyCt The address of the concerned currency contract (address(0) == ETH)/currencyId The ID of the concerned currency (0 for ETH and ERC20)/index The concerned r...
function fungibleRecordByIndex(address wallet, bytes32 _type, address currencyCt, uint256 currencyId, uint256 index) public view returns (int256 amount, uint256 blockNumber)
function fungibleRecordByIndex(address wallet, bytes32 _type, address currencyCt, uint256 currencyId, uint256 index) public view returns (int256 amount, uint256 blockNumber)
29,048
3
// parts[1] e parts[2]
if (greatness > 900) { parts[1] = "Text 1 un"; uint serial = 1000000000 + rand % 100000000; parts[3] = toString (serial); } else if (greatness > 500) {
if (greatness > 900) { parts[1] = "Text 1 un"; uint serial = 1000000000 + rand % 100000000; parts[3] = toString (serial); } else if (greatness > 500) {
24,246