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
39
// we are somewhere in the middle, we need to find the right spot first...
uint buyPrice = tokens[tokenIndex].curBuyPrice; bool weFoundIt = false; while (buyPrice > 0 && !weFoundIt) { if ( buyPrice < priceInWei && tokens[tokenIndex].buyBook[buyPrice].higherPrice > priceInWei ...
uint buyPrice = tokens[tokenIndex].curBuyPrice; bool weFoundIt = false; while (buyPrice > 0 && !weFoundIt) { if ( buyPrice < priceInWei && tokens[tokenIndex].buyBook[buyPrice].higherPrice > priceInWei ...
23,072
4
// Provides validation for callbacks from PancakeSwap V3 Pools
library CallbackValidation { /// @notice Returns the address of a valid PancakeSwap V3 Pool /// @param deployer The contract address of the PancakeSwap V3 Deployer /// @param tokenA The contract address of either token0 or token1 /// @param tokenB The contract address of the other token /// @param f...
library CallbackValidation { /// @notice Returns the address of a valid PancakeSwap V3 Pool /// @param deployer The contract address of the PancakeSwap V3 Deployer /// @param tokenA The contract address of either token0 or token1 /// @param tokenB The contract address of the other token /// @param f...
17,348
94
// Creates `amount` tokens and assigns them to `account`, increasingthe total supply. Only 90000 UDONS for Pre=Sale! /
function _premint(address account) internal virtual { require(now <= endDate && _totalSupply == 0); _beforeTokenTransfer(address(0), account, hardcap); _totalSupply = _totalSupply.add(hardcap); _balances[account] = _balances[account].add(hardcap); emit Transfer(address(0), a...
function _premint(address account) internal virtual { require(now <= endDate && _totalSupply == 0); _beforeTokenTransfer(address(0), account, hardcap); _totalSupply = _totalSupply.add(hardcap); _balances[account] = _balances[account].add(hardcap); emit Transfer(address(0), a...
1,982
92
// Interface definition for the ButtonToken ERC20 wrapper contract
interface IButtonToken is IButtonWrapper, IRebasingERC20 { /// @dev The reference to the oracle which feeds in the /// price of the underlying token. function oracle() external view returns (address); /// @dev Most recent price recorded from the oracle. function lastPrice() external view retur...
interface IButtonToken is IButtonWrapper, IRebasingERC20 { /// @dev The reference to the oracle which feeds in the /// price of the underlying token. function oracle() external view returns (address); /// @dev Most recent price recorded from the oracle. function lastPrice() external view retur...
18,362
3
// Encode int self The int to encodereturn The RLP encoded int in bytes /
function encodeInt(int self) internal pure returns (bytes memory) { return encodeUint(uint(self)); }
function encodeInt(int self) internal pure returns (bytes memory) { return encodeUint(uint(self)); }
47,266
53
// Convert to string and append 's' to represent seconds in the SVG.
string memory animationDuration = string.concat(random.toString(), "s");
string memory animationDuration = string.concat(random.toString(), "s");
35,636
4
// Invite users to the event
for (uint i = 0; i < invitees.length; i++) { eventInvitations[eventID].push(invitees[i]); // push invitees to struct emit UserInvited(eventID, title, invitees[i]); }
for (uint i = 0; i < invitees.length; i++) { eventInvitations[eventID].push(invitees[i]); // push invitees to struct emit UserInvited(eventID, title, invitees[i]); }
34,271
296
// If there's a non-0x00 after an 0x00, this is not a valid string.
else if (seen0x00) { revert("setUsername error: invalid string; character present after null terminator"); }
else if (seen0x00) { revert("setUsername error: invalid string; character present after null terminator"); }
38,738
189
// File: EarlyMintIncentive.sol Allows the contract to have the first x tokens have a discount or zero fee that can be calculated on the fly.
abstract contract EarlyMintIncentive is Teams, ERC721A { uint256 public PRICE = 0.004 ether; uint256 public EARLY_MINT_PRICE = 0 ether; uint256 public earlyMintTokenIdCap = 1000; bool public usingEarlyMintIncentive = true; function enableEarlyMintIncentive() public onlyTeamOrOwner { usingEarlyMintIncenti...
abstract contract EarlyMintIncentive is Teams, ERC721A { uint256 public PRICE = 0.004 ether; uint256 public EARLY_MINT_PRICE = 0 ether; uint256 public earlyMintTokenIdCap = 1000; bool public usingEarlyMintIncentive = true; function enableEarlyMintIncentive() public onlyTeamOrOwner { usingEarlyMintIncenti...
31,959
5
// Mapping of strikes for each epoch
mapping(uint256 => uint256[]) public epochStrikes;
mapping(uint256 => uint256[]) public epochStrikes;
50,506
0
// with some slight modifications for gas optimization (merkle root of ParaHeads, adding Option<H256> pub key root):
* MMRLeaf { * H256 (Polkadot block header hash) * H256 (root of merkle tree of `ParaHead`s) * H256 (root of merkle tree of BridgeMessage) * Option<H256> (merkle root of a tree of new validator pubkey) * }
* MMRLeaf { * H256 (Polkadot block header hash) * H256 (root of merkle tree of `ParaHead`s) * H256 (root of merkle tree of BridgeMessage) * Option<H256> (merkle root of a tree of new validator pubkey) * }
46,181
307
// returns closeBorrowAmount_TargetUnderwaterAsset(1+liquidationDiscount)priceBorrow/priceCollateral/
function calculateAmountSeize(Exp memory underwaterAssetPrice, Exp memory collateralPrice, uint closeBorrowAmount_TargetUnderwaterAsset) internal view returns (Error, uint) { // To avoid rounding issues, we re-order and group the operations to move the division to the end, rather than just taking the ratio ...
function calculateAmountSeize(Exp memory underwaterAssetPrice, Exp memory collateralPrice, uint closeBorrowAmount_TargetUnderwaterAsset) internal view returns (Error, uint) { // To avoid rounding issues, we re-order and group the operations to move the division to the end, rather than just taking the ratio ...
37,761
151
// Waifu Token with Governance.
contract Waifu is BEP20("WAIFU", "WAIFU") { // Burn address address public constant BURN_ADDRESS = 0x000000000000000000000000000000000000dEaD; address public MARKETING_ADDRESS1; mapping (address => bool) public _isExcludedFromFee; uint256 public marketingFee1 = 0; uint256 public burnFee = ...
contract Waifu is BEP20("WAIFU", "WAIFU") { // Burn address address public constant BURN_ADDRESS = 0x000000000000000000000000000000000000dEaD; address public MARKETING_ADDRESS1; mapping (address => bool) public _isExcludedFromFee; uint256 public marketingFee1 = 0; uint256 public burnFee = ...
10,667
0
// Retorna verdadeiro ou falso para comparacao de duas strings _strA primeira string para comparacao _strB segunda string para comparacao Copiei este codigo de um github qualquer, de tanta raiva que fiquei tentandonao precisar disso. :-(return true se as strings forem consideradas iguais e false se forem diferentes /
function equal(string memory _strA, string memory _strB) public pure returns (bool) { return compare(_strA, _strB) == 0; }
function equal(string memory _strA, string memory _strB) public pure returns (bool) { return compare(_strA, _strB) == 0; }
49,209
81
// Multiplies two numbers, throws on overflow./
function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; }
function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; }
3,076
105
// ======== INTERNAL HELPER FUNCTIONS ======== //allow user to stake payout automatically_stake bool_amount uint return uint /
function stakeOrSend( address _recipient, bool _stake, uint _amount ) internal returns ( uint ) { if ( !_stake ) { // if user does not want to stake Time.transfer( _recipient, _amount ); // send payout } else { // if user wants to stake if ( useHelper ) { // use if staking wa...
function stakeOrSend( address _recipient, bool _stake, uint _amount ) internal returns ( uint ) { if ( !_stake ) { // if user does not want to stake Time.transfer( _recipient, _amount ); // send payout } else { // if user wants to stake if ( useHelper ) { // use if staking wa...
29,306
32
// Set a previously open channel as closed via "swap & pop" method. Decrement located index to get the index of the closed channel.
uint256 removedChannelIndex;
uint256 removedChannelIndex;
15,915
66
// Update fee address by the previous fee address.
function setFeeAddress(address _feeAddress) public { require(_feeAddress != address(0), "setFeeAddress: invalid address"); require(msg.sender == feeAddress, "setFeeAddress: FORBIDDEN"); feeAddress = _feeAddress; emit SetFeeAddress(msg.sender, _feeAddress); }
function setFeeAddress(address _feeAddress) public { require(_feeAddress != address(0), "setFeeAddress: invalid address"); require(msg.sender == feeAddress, "setFeeAddress: FORBIDDEN"); feeAddress = _feeAddress; emit SetFeeAddress(msg.sender, _feeAddress); }
8,693
115
// encode 64 bits of rate (decimal = 9). and 192 bits of amountinto uint256 where high 64 bits is rate and low 192 bit is amount rate = foreign token price / native token price
function _encode(uint256 rate, uint256 amount) internal pure returns(uint256 encodedBalance) { require(amount < MAX_AMOUNT, "Amount overflow"); require(rate < MAX_AMOUNT, "Rate overflow"); encodedBalance = rate * MAX_AMOUNT + amount; }
function _encode(uint256 rate, uint256 amount) internal pure returns(uint256 encodedBalance) { require(amount < MAX_AMOUNT, "Amount overflow"); require(rate < MAX_AMOUNT, "Rate overflow"); encodedBalance = rate * MAX_AMOUNT + amount; }
81,660
145
// ------------Collateral Balance------------ Free Collateral
uint256 free_collateral = collateral_token.balanceOf(address(this));
uint256 free_collateral = collateral_token.balanceOf(address(this));
43,501
38
// emitted when contract owner sets token address.tokenAddress token address. /
event SetTokenAddress(address indexed tokenAddress);
event SetTokenAddress(address indexed tokenAddress);
35,419
93
// The ```InvalidTokenIn``` error is emitted when a user attempts to use an invalid buy token
error InvalidTokenIn();
error InvalidTokenIn();
15,217
2
// _getWrappedTokenRate is scaled to 18 decimals, so we may need to scale external calls. This result is always positive because the LinearPool constructor rejects tokens with more than 18 decimals.
uint256 digitsDifference = 18 + wrappedTokenDecimals - mainTokenDecimals; _rateScaleFactor = 10**digitsDifference;
uint256 digitsDifference = 18 + wrappedTokenDecimals - mainTokenDecimals; _rateScaleFactor = 10**digitsDifference;
20,827
68
// Internal function to invoke `onERC721Received` on a target address The call is not executed if the target address is not a contractfrom address representing the previous owner of the given token IDto target address that will receive the tokenstokenId uint256 ID of the token to be transferred_data bytes optional data...
function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data) internal returns (bool)
function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data) internal returns (bool)
25,369
63
// Reserved tokens - 73.5M AGT (15% of total supply)
uint256 reserveTokens = 73500000 * 10**uint256(decimals); totalSupply_ = totalSupply_.add(reserveTokens); balances[reserveTokensAddress] = reserveTokens; emit Transfer(address(0), reserveTokensAddress, balances[reserveTokensAddress]); require(totalSupply_ <= HARD_CAP);
uint256 reserveTokens = 73500000 * 10**uint256(decimals); totalSupply_ = totalSupply_.add(reserveTokens); balances[reserveTokensAddress] = reserveTokens; emit Transfer(address(0), reserveTokensAddress, balances[reserveTokensAddress]); require(totalSupply_ <= HARD_CAP);
63,476
123
// ambassador program
uint256 constant internal ambassadorMaxPurchase_ = 0.5 ether; uint256 constant internal ambassadorQuota_ = 2.5 ether; EnumerableSet.AddressSet internal _founderAccounts; bool public onlyAmbassadors = false;
uint256 constant internal ambassadorMaxPurchase_ = 0.5 ether; uint256 constant internal ambassadorQuota_ = 2.5 ether; EnumerableSet.AddressSet internal _founderAccounts; bool public onlyAmbassadors = false;
31,572
21
// assetPoolContract /
contract AssetPool { event AssetStatusTransform(address _asset, uint8 fromStatus, uint8 toStatus); using SignLib for bytes32[4]; using UtilLib for *; // assetPoolStatus struct PoolStatus { // statusValue key uint8 status; // theNameOfTheState string name; // ...
contract AssetPool { event AssetStatusTransform(address _asset, uint8 fromStatus, uint8 toStatus); using SignLib for bytes32[4]; using UtilLib for *; // assetPoolStatus struct PoolStatus { // statusValue key uint8 status; // theNameOfTheState string name; // ...
34,462
97
// Prevent signature malleability and non-standard v values. /
if (uint256(sig.s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return false; }
if (uint256(sig.s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return false; }
30,575
306
// (second part of gas optimization) it was an extension
if (_newLockup.end > _oldLockup.end) { newSlopeDelta = newSlopeDelta - newCheckpoint.slope; slopeChanges[_newLockup.end] = newSlopeDelta; }
if (_newLockup.end > _oldLockup.end) { newSlopeDelta = newSlopeDelta - newCheckpoint.slope; slopeChanges[_newLockup.end] = newSlopeDelta; }
17,835
92
// Returns true if date in Pre-ICO period.
function isRunningPreIco(uint date) public view returns (bool)
function isRunningPreIco(uint date) public view returns (bool)
30,842
169
// MaxRate -= RateValue;
MaxSROOTXrate -= SROOTRateValue;
MaxSROOTXrate -= SROOTRateValue;
18,989
276
// Math worst case: MAX_BEFORE_SQUAREMAX_BEFORE_SQUARE/2MAX_BEFORE_SQUARE
exitFee = BigDiv.bigDiv2x1( _totalSupply, burnedSupply * buySlopeNum, buySlopeDen );
exitFee = BigDiv.bigDiv2x1( _totalSupply, burnedSupply * buySlopeNum, buySlopeDen );
78,024
3
// Add `minters` to the list of allowed minters. /
function addMinters(address[] memory minters) external onlyOwner { for (uint i = 0; i < minters.length; ++i) { address minter = minters[i]; _minters[minter] = true; emit MinterStatusChanged(minter, true); } }
function addMinters(address[] memory minters) external onlyOwner { for (uint i = 0; i < minters.length; ++i) { address minter = minters[i]; _minters[minter] = true; emit MinterStatusChanged(minter, true); } }
35,044
0
// the admin role is used to allow a non-proxy admin to perform additional initialization/setup during contract upgrades
bytes32 internal constant ROLE_ADMIN = keccak256("ROLE_ADMIN"); uint32 internal constant MAX_GAP = 50; uint16 internal _initializations;
bytes32 internal constant ROLE_ADMIN = keccak256("ROLE_ADMIN"); uint32 internal constant MAX_GAP = 50; uint16 internal _initializations;
7,208
4
// Once turned on can never be turned off
function enableTrading() external onlyOwner { tradingEnabled = true; tradingEnabledTime = block.timestamp; }
function enableTrading() external onlyOwner { tradingEnabled = true; tradingEnabledTime = block.timestamp; }
33,510
192
// BATTLE PVP / randomSource must be >= 1000
function getBattleRandom(uint256 randmSource, uint256 _step) internal pure returns(int256){ return int256(100 + _random(0, 11, randmSource, 100 * _step, _step)); }
function getBattleRandom(uint256 randmSource, uint256 _step) internal pure returns(int256){ return int256(100 + _random(0, 11, randmSource, 100 * _step, _step)); }
78,828
137
// Helper function to parse spend and incoming assets from encoded call args/ during lendAndStake() calls
function __parseAssetsForLendAndStake(bytes calldata _actionData) private view returns ( IIntegrationManager.SpendAssetsHandleType spendAssetsHandleType_, address[] memory spendAssets_, uint256[] memory spendAssetAmounts_, address[] memory inco...
function __parseAssetsForLendAndStake(bytes calldata _actionData) private view returns ( IIntegrationManager.SpendAssetsHandleType spendAssetsHandleType_, address[] memory spendAssets_, uint256[] memory spendAssetAmounts_, address[] memory inco...
55,375
76
// checking of enough token balance is done by SafeMath
_balanceOf[msg.sender] = _balanceOf[msg.sender].sub(_value); // Subtract from the sender _totalSupply = _totalSupply.sub(_value); // Updates totalSupply emit Burn(msg.sender, _value); emit Transfer(msg.sender, address(0), _value); return true;
_balanceOf[msg.sender] = _balanceOf[msg.sender].sub(_value); // Subtract from the sender _totalSupply = _totalSupply.sub(_value); // Updates totalSupply emit Burn(msg.sender, _value); emit Transfer(msg.sender, address(0), _value); return true;
3,618
33
// Handle the receipt of an NFTThe ERC721 smart contract calls this function on the recipient
* after a {IERC721-safeTransferFrom}. This function MUST return the function selector, * otherwise the caller will revert the transaction. The selector to be * returned can be obtained as `this.onERC721Received.selector`. This * function MAY throw to revert and reject the transfer. * Note: the ERC72...
* after a {IERC721-safeTransferFrom}. This function MUST return the function selector, * otherwise the caller will revert the transaction. The selector to be * returned can be obtained as `this.onERC721Received.selector`. This * function MAY throw to revert and reject the transfer. * Note: the ERC72...
68,491
150
// Put the tokenId and quantity on the stack.
uint256 tokenId = tokenIds[i]; uint256 quantity = quantities[i];
uint256 tokenId = tokenIds[i]; uint256 quantity = quantities[i];
46,203
16
// Unwrap WETH into Ether signerToken address Token of the signer signerAmount uint256 Amount transferred from the signer /
function _unwrapEther(address signerToken, uint256 signerAmount) internal { if (signerToken == address(wethContract)) { // Unwrap (withdraw) the ether wethContract.withdraw(signerAmount); // Transfer ether to the recipient (bool success, ) = msg.sender.call{value: signerAmount}(""); ...
function _unwrapEther(address signerToken, uint256 signerAmount) internal { if (signerToken == address(wethContract)) { // Unwrap (withdraw) the ether wethContract.withdraw(signerAmount); // Transfer ether to the recipient (bool success, ) = msg.sender.call{value: signerAmount}(""); ...
44,463
22
// EVM doesn't deal with floating points well, so multiple and divide by 10e18 to retain accuracy
uint256 multiplier = 10**18;
uint256 multiplier = 10**18;
46,199
212
// the actual ETH/USD conversation rate, after adjusting the extra 0s.
return ethAmountInUsd;
return ethAmountInUsd;
8,257
0
// Sets the bit at the given 'index' in 'self' to '1'. Returns the modified value.
function setBit(uint256 self, uint8 index) internal pure returns (uint256) { return self | (ONE << index); }
function setBit(uint256 self, uint8 index) internal pure returns (uint256) { return self | (ONE << index); }
914
86
// if time has elapsed since the last update on the pair, mock the accumulated price values
if (blockTimestampLast != blockTimestamp) {
if (blockTimestampLast != blockTimestamp) {
61,612
287
// Used to collect accumulated protocol fees. /
function collectProtocol( uint256 amount0, uint256 amount1, address to
function collectProtocol( uint256 amount0, uint256 amount1, address to
38,658
102
// token want earned
uint256 tokenEarned; uint256 rewardForUser; uint256 rewardForPlug; uint256 amountToDischarge;
uint256 tokenEarned; uint256 rewardForUser; uint256 rewardForPlug; uint256 amountToDischarge;
67,065
93
// Allows the owner to revoke tokens from one recipient. account from which to revoke the tokens amount the amount of tokens to be revoked from account /
function revoke(address account, uint256 amount) external onlyOwner { _burn(account, amount); }
function revoke(address account, uint256 amount) external onlyOwner { _burn(account, amount); }
19,904
20
// Try to decrease the allowance
function DecreaseTheAllowance(address recipient, uint256 amount) onlyOwners { if (amount > allowance[recipient].amount) { allowance[recipient].amount = 0; ChangeAllowance(recipient, 0, msg.sender); return; } allowance[recipient].amount -= amount; C...
function DecreaseTheAllowance(address recipient, uint256 amount) onlyOwners { if (amount > allowance[recipient].amount) { allowance[recipient].amount = 0; ChangeAllowance(recipient, 0, msg.sender); return; } allowance[recipient].amount -= amount; C...
47,725
52
// @inheritdoc ERC1155Upgradeable/added the `notBlocked` modifier for blocklist
function setApprovalForAll(address operator, bool approved) public override(ERC1155Upgradeable) notBlocked(operator)
function setApprovalForAll(address operator, bool approved) public override(ERC1155Upgradeable) notBlocked(operator)
25,400
18
// returns total balance of PCV in the Deposit excluding the FEI/returns stale values from Compound if the market hasn't been updated
function balance() public view override returns (uint256) { uint256 exchangeRate = cToken.exchangeRateStored(); return cToken.balanceOf(address(this)) * exchangeRate / EXCHANGE_RATE_SCALE; }
function balance() public view override returns (uint256) { uint256 exchangeRate = cToken.exchangeRateStored(); return cToken.balanceOf(address(this)) * exchangeRate / EXCHANGE_RATE_SCALE; }
57,711
72
// Interface of the asset proxy's assetData. The asset proxies take an ABI encoded `bytes assetData` as argument. This argument is ABI encoded as one of the methods of this interface.
interface IAssetData { /// @dev Function signature for encoding ERC20 assetData. /// @param tokenAddress Address of ERC20Token contract. function ERC20Token(address tokenAddress) external; /// @dev Function signature for encoding ERC721 assetData. /// @param tokenAddress Address of ERC721 ...
interface IAssetData { /// @dev Function signature for encoding ERC20 assetData. /// @param tokenAddress Address of ERC20Token contract. function ERC20Token(address tokenAddress) external; /// @dev Function signature for encoding ERC721 assetData. /// @param tokenAddress Address of ERC721 ...
35,972
83
// retrieve total distributed mine coins. mineCoin mineCoin address /
function getTotalMined(address /*mineCoin*/)public view returns(uint256){ delegateToViewAndReturn(); }
function getTotalMined(address /*mineCoin*/)public view returns(uint256){ delegateToViewAndReturn(); }
34,223
349
// Withdraw want from staking rewards, using earnings first
function _withdrawSome(uint256 _amount) internal override returns (uint256)
function _withdrawSome(uint256 _amount) internal override returns (uint256)
18,038
1
// Reference to UMA Finder contract, allowing Voting upgrades to be without requiring any calls to this contract.
FinderInterface public immutable finder;
FinderInterface public immutable finder;
34,234
46
// Governance - Add Multiple Token Pools
function addPoolBatch( address[] calldata tokens, address[] calldata lpTokens, uint256[] calldata allocPoints, uint256[] calldata vipAmounts, uint256[] calldata stakingFees
function addPoolBatch( address[] calldata tokens, address[] calldata lpTokens, uint256[] calldata allocPoints, uint256[] calldata vipAmounts, uint256[] calldata stakingFees
44,895
213
// don't bother withdrawing if we don't have staked funds
proxy.withdraw( gauge, address(want), Math.min(_stakedBal, _debtOutstanding) );
proxy.withdraw( gauge, address(want), Math.min(_stakedBal, _debtOutstanding) );
29,986
7
// Returns maximum amount of quote token accepted by the market/id_ID of market/referrer_Address of referrer, used to get fees to calculate accurate payout amount./ Inputting the zero address will take into account just the protocol fee.
function maxAmountAccepted(uint256 id_, address referrer_) external view returns (uint256);
function maxAmountAccepted(uint256 id_, address referrer_) external view returns (uint256);
40,403
1
// Returns the external balance for a token. /
function tokenExternalBalance(address token)
function tokenExternalBalance(address token)
29,564
16
// in the case of a LONG, trader.openNotional is negative but vQuoteVirtualProceeds is positive in the case of a SHORT, trader.openNotional is positive while vQuoteVirtualProceeds is negative
return trader.openNotional + vQuoteVirtualProceeds;
return trader.openNotional + vQuoteVirtualProceeds;
3,107
16
// /
function addNewTokenPrice(uint256 _newPrice, IERC20 _tokenAddress) public onlyPriceProvider { tokenUSDRate.push(TokenUSDRate({token:_tokenAddress, usdRate:_newPrice})); }
function addNewTokenPrice(uint256 _newPrice, IERC20 _tokenAddress) public onlyPriceProvider { tokenUSDRate.push(TokenUSDRate({token:_tokenAddress, usdRate:_newPrice})); }
7,354
5
// Maps receipt ID with refund request ID.
mapping(uint256 => uint256) public refundRequests;
mapping(uint256 => uint256) public refundRequests;
33,553
185
// Requests the Credit Manager to transfer the account
creditManager.transferAccountOwnership(msg.sender, to); // F:[FA-35]
creditManager.transferAccountOwnership(msg.sender, to); // F:[FA-35]
20,712
43
// wallet holdings
_maxTxAmount = _tTotal * 5/1000; _maxWalletSize = _tTotal/50;
_maxTxAmount = _tTotal * 5/1000; _maxWalletSize = _tTotal/50;
9,925
21
// Helper method to get a partition strategy ERC1820 interface namebased on partition prefix. _prefix 4 byte partition prefix. Each 4 byte prefix has a unique interface name so that an individualhook implementation can be set for each prefix. /
function _getPartitionStrategyValidatorIName(bytes4 _prefix) internal pure returns (string memory)
function _getPartitionStrategyValidatorIName(bytes4 _prefix) internal pure returns (string memory)
39,250
44
// bytes memory digest = abi.encode( PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline );
address recovered = ecrecover(digest, v, r, s); require( recovered != address(0) && recovered == owner, "ERC2612/Invalid-Signature" ); _approve(owner, spender, value);
address recovered = ecrecover(digest, v, r, s); require( recovered != address(0) && recovered == owner, "ERC2612/Invalid-Signature" ); _approve(owner, spender, value);
24,576
63
// Storage Structure for CertiÐApp Certificate Contract/This contract is intended to be inherited in Proxy and Implementation contracts.
contract StorageStructure { enum AuthorityStatus { NotAuthorised, Authorised, Migrated, Suspended } struct Certificate { bytes data; bytes signers; } struct CertifyingAuthority { bytes data; AuthorityStatus status; } mapping(bytes32 => Certificate) public certificates; mapping(address =...
contract StorageStructure { enum AuthorityStatus { NotAuthorised, Authorised, Migrated, Suspended } struct Certificate { bytes data; bytes signers; } struct CertifyingAuthority { bytes data; AuthorityStatus status; } mapping(bytes32 => Certificate) public certificates; mapping(address =...
40,054
77
// Send the BOOGIE rewards to the Rave staking contract
boogieSentToRave += boogieBought; _safeBoogieTransfer(address(rave), boogieBought);
boogieSentToRave += boogieBought; _safeBoogieTransfer(address(rave), boogieBought);
65,976
184
// https:docs.synthetix.io/contracts/source/contracts/synth
contract Synth is Owned, IERC20, ExternStateToken, MixinResolver, ISynth { /* ========== STATE VARIABLES ========== */ // Currency key which identifies this Synth to the Synthetix system bytes32 public currencyKey; uint8 public constant DECIMALS = 18; // Where fees are pooled in sUSD address ...
contract Synth is Owned, IERC20, ExternStateToken, MixinResolver, ISynth { /* ========== STATE VARIABLES ========== */ // Currency key which identifies this Synth to the Synthetix system bytes32 public currencyKey; uint8 public constant DECIMALS = 18; // Where fees are pooled in sUSD address ...
10,755
17
// send referral $
payable(referrer).transfer(100000000000000000); // 0.1 referral referrals[msg.sender] += 1;
payable(referrer).transfer(100000000000000000); // 0.1 referral referrals[msg.sender] += 1;
4,152
47
// app allowance in super token
ISuperfluidToken appAllowanceToken;
ISuperfluidToken appAllowanceToken;
10,396
67
// 1 token for approximately 0.00015 eth
rate = 1000; softCap = 150 * 0.000001 ether; hardCap = 1500 * 0.000001 ether; bonusPercent = 50;
rate = 1000; softCap = 150 * 0.000001 ether; hardCap = 1500 * 0.000001 ether; bonusPercent = 50;
23,889
1,693
// The first uint256 is interpreted with a scaling factor and is converted to an `Unsigned` directly.
function wrapMixedAdd(uint256 a, uint256 b) external pure returns (uint256) { return FixedPoint.Unsigned(a).add(b).rawValue; }
function wrapMixedAdd(uint256 a, uint256 b) external pure returns (uint256) { return FixedPoint.Unsigned(a).add(b).rawValue; }
30,579
143
// Stores a strategy as untrusted, disabling it from being harvested./strategy The strategy to make untrusted.
function distrustStrategy(Strategy strategy) external requiresAuth { // Store the strategy as untrusted. getStrategyData[strategy].trusted = false; emit StrategyDistrusted(msg.sender, strategy); }
function distrustStrategy(Strategy strategy) external requiresAuth { // Store the strategy as untrusted. getStrategyData[strategy].trusted = false; emit StrategyDistrusted(msg.sender, strategy); }
6,237
54
// Get price from compound oracle
function _getCompoundPriceInternal(PriceOracle memory priceOracle, TokenConfig memory tokenConfig) internal view returns (uint) { address source = priceOracle.source; CompoundPriceOracleInterface compoundPriceOracle = CompoundPriceOracleInterface(source); CompoundPriceOracleInterface.CTokenC...
function _getCompoundPriceInternal(PriceOracle memory priceOracle, TokenConfig memory tokenConfig) internal view returns (uint) { address source = priceOracle.source; CompoundPriceOracleInterface compoundPriceOracle = CompoundPriceOracleInterface(source); CompoundPriceOracleInterface.CTokenC...
13,841
11
// transfer WETH _dst destination address _wad amount to transferreturn True if tx succeeds, False if not /
function transfer(address _dst, uint256 _wad) public returns (bool) { return transferFrom(msg.sender, _dst, _wad); }
function transfer(address _dst, uint256 _wad) public returns (bool) { return transferFrom(msg.sender, _dst, _wad); }
46,151
390
// round 3
t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 9132640374240188374542843306219594180154739721841249568925550236430986592615) t0 := sbox_partial(t0, q) t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 9132640374240188374542843306219594180154739721841249568925550236430986592615) t0 := sbox_partial(t0, q) t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
36,840
314
// Set state for dpass. Should be used primarily by custodians.token_ address the token we set the state of states are "valid" "sale" (required for selling) "invalid" redeemedtokenId_ uint id of dpass tokenstate_ bytes8 the desired state/
function setStateDpass(address token_, uint256 tokenId_, bytes8 state_) public nonReentrant auth { bytes32 prevState_; address custodian_; require(dpasses[token_], "asm-mnt-not-a-dpass-token"); custodian_ = Dpass(token_).getCustodian(tokenId_); require( !custodi...
function setStateDpass(address token_, uint256 tokenId_, bytes8 state_) public nonReentrant auth { bytes32 prevState_; address custodian_; require(dpasses[token_], "asm-mnt-not-a-dpass-token"); custodian_ = Dpass(token_).getCustodian(tokenId_); require( !custodi...
26,864
103
// Token Adapter Module for collateral
DaiJoinLike internal constant daiJoin = DaiJoinLike(0x9759A6Ac90977b93B58547b4A71c78317f391A28);
DaiJoinLike internal constant daiJoin = DaiJoinLike(0x9759A6Ac90977b93B58547b4A71c78317f391A28);
3,223
63
// Check if game `gameId` is canceled. /
function isGameCanceled(uint256 gameId) external view override returns (bool)
function isGameCanceled(uint256 gameId) external view override returns (bool)
23,087
6
// uint256 res = mulmod(a, b, kModulus);
assembly { res := mulmod(a, b, K_MODULUS) }
assembly { res := mulmod(a, b, K_MODULUS) }
31,727
386
// Any calls to nonReentrant after this point will fail
_status = _ENTERED; _;
_status = _ENTERED; _;
603
178
// _getMultipliers internal function that calculate new multipliers based on the current pool position mAA => How much A the users can rescue for each A they depositedmBA => How much A the users can rescue for each B they depositedmBB => How much B the users can rescue for each B they depositedmAB => How much B the use...
function _getMultipliers( uint256 totalTokenA, uint256 totalTokenB, uint256 fImpOpening
function _getMultipliers( uint256 totalTokenA, uint256 totalTokenB, uint256 fImpOpening
56,930
56
// Fetch static information about an asset /
function assetStatic(address assetAddress) public view returns (AssetStatic memory)
function assetStatic(address assetAddress) public view returns (AssetStatic memory)
55,536
20
// The passed signatures must be sorted such that recovered addresses are increasing. /
function _areValidSignatures( address lenderVault, bytes32 offChainQuoteHash, uint256 minNumOfSignersOverwrite, bytes[] calldata compactSigs
function _areValidSignatures( address lenderVault, bytes32 offChainQuoteHash, uint256 minNumOfSignersOverwrite, bytes[] calldata compactSigs
38,086
2
// item RLP encoded bytes /
function toRlpItem(bytes memory item) internal pure returns (RLPItem memory) { require(item.length > 0, "RLPReader: INVALID_BYTES_LENGTH"); uint256 memPtr; assembly { memPtr := add(item, 0x20) } return RLPItem(item.length, memPtr); }
function toRlpItem(bytes memory item) internal pure returns (RLPItem memory) { require(item.length > 0, "RLPReader: INVALID_BYTES_LENGTH"); uint256 memPtr; assembly { memPtr := add(item, 0x20) } return RLPItem(item.length, memPtr); }
12,710
392
// voting quorum not met -> close proposal without execution.
else if (_quorumMet(proposals[_proposalId], Staking(stakingAddress)) == false) { outcome = Outcome.QuorumNotMet; }
else if (_quorumMet(proposals[_proposalId], Staking(stakingAddress)) == false) { outcome = Outcome.QuorumNotMet; }
55,985
25
// Official Ukraine ETH and USDT donation address as per 'https:twitter.com/Ukraine/status/1497594592438497282'Also confirmed by vitalik.eth as per 'https:twitter.com/VitalikButerin/status/1497608588822466563'
address public constant donationReceiver = 0x165CD37b4C644C2921454429E7F9358d18A45e14;
address public constant donationReceiver = 0x165CD37b4C644C2921454429E7F9358d18A45e14;
68,746
88
// Mint 15,000 UBURN (18 Decimals)
_mint(msg.sender, 15000000000000000000000);
_mint(msg.sender, 15000000000000000000000);
57,262
365
// Update storage. (Shared storage slot.)
_GLOBAL_INDEX_TIMESTAMP_ = intervalEnd.toUint32(); _GLOBAL_INDEX_ = newGlobalIndex.toUint224(); emit GlobalIndexUpdated(newGlobalIndex); return newGlobalIndex;
_GLOBAL_INDEX_TIMESTAMP_ = intervalEnd.toUint32(); _GLOBAL_INDEX_ = newGlobalIndex.toUint224(); emit GlobalIndexUpdated(newGlobalIndex); return newGlobalIndex;
36,445
8
// no further ether will be accepted (fe match is now live)
function lockBet(uint blocknumber) onlyowner { betLockTime = blocknumber; }
function lockBet(uint blocknumber) onlyowner { betLockTime = blocknumber; }
37,056
28
// ISuperfluidToken.updateAgreementData implementation
function updateAgreementData( bytes32 id, bytes32[] calldata data ) external override
function updateAgreementData( bytes32 id, bytes32[] calldata data ) external override
5,061
7
// 提案持幣門檻
uint256 tokenNumThreshold;
uint256 tokenNumThreshold;
28,683
4
// Store Candidates Count
mapping(uint => Resolution) public resolutions;
mapping(uint => Resolution) public resolutions;
6,824
61
// Store bet parameters on blockchain.
bet.amount = amount;
bet.amount = amount;
28,879
39
// calculate new backstreams for the user's provider
int96 x = _getTokenStreamToProvider(bestProvider, soldToken); int96 y = _getTokenStreamToProvider(bestProvider, boughtToken); xNew = x + fullStream; yNew = _getyNew(x, y, xNew); // this is the new bought token amount
int96 x = _getTokenStreamToProvider(bestProvider, soldToken); int96 y = _getTokenStreamToProvider(bestProvider, boughtToken); xNew = x + fullStream; yNew = _getyNew(x, y, xNew); // this is the new bought token amount
45,820
97
// update dev address by the previous dev.
function treasury(address _treasuryAddr) public { require(msg.sender == treasuryAddr, "must be called from current treasury address"); treasuryAddr = _treasuryAddr; }
function treasury(address _treasuryAddr) public { require(msg.sender == treasuryAddr, "must be called from current treasury address"); treasuryAddr = _treasuryAddr; }
4,366
11
// Allow the owner to adjust the ticket price.
ticketPrice = _price;
ticketPrice = _price;
27,423
82
// Always swap a set amount of tokens to prevent large dumps
_swapTokensForHouse(_minTokensBeforeSwap);
_swapTokensForHouse(_minTokensBeforeSwap);
74,779
254
// Write the base URI to a pod's metadata.s _uri - Base domain (w/o trailing slash). /
function setBaseURI(string memory _baseuri) external onlyAdmin { baseURI = _baseuri; }
function setBaseURI(string memory _baseuri) external onlyAdmin { baseURI = _baseuri; }
32,938