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
149
// default tax is 7.5% of every transfer
uint256 taxAmount = amount.mul(transferTaxRate).div(10000); uint256 burnAmount = taxAmount.mul(burnRate).div(100); uint256 liquidityAmount = taxAmount.sub(burnAmount); require(taxAmount == burnAmount + liquidityAmount, "SHARK::transfer: Burn value invalid");
uint256 taxAmount = amount.mul(transferTaxRate).div(10000); uint256 burnAmount = taxAmount.mul(burnRate).div(100); uint256 liquidityAmount = taxAmount.sub(burnAmount); require(taxAmount == burnAmount + liquidityAmount, "SHARK::transfer: Burn value invalid");
4,414
9
// Returns the NFTLabStorage address to interact with nfts.The trade logic handles everything that regards moving tokenswhen they are put on a trade (so that owners cannot open atrade and then move them), this way the owner of an nft can dowhatever he wants with it, even give it for free to someoneelse /
function getStorage() external view returns (address) { return address(tokenHandler); }
function getStorage() external view returns (address) { return address(tokenHandler); }
32,950
29
// Create a new NokuTokenBurner with predefined burning fraction._wallet The wallet receiving the unburnt tokens./
function NokuTokenBurner(address _wallet) public { require(_wallet != address(0)); wallet = _wallet; burningPercentage = 100; LogNokuTokenBurnerCreated(msg.sender, _wallet); }
function NokuTokenBurner(address _wallet) public { require(_wallet != address(0)); wallet = _wallet; burningPercentage = 100; LogNokuTokenBurnerCreated(msg.sender, _wallet); }
19,270
19
// sum user deposit passionnum
function balanceOf(address _voter) external view returns (uint256) { uint256 _votes = 0; uint256 _vCtLpTotal; uint256 _vUserLp; uint256 _vCtPassionNum; uint256 _vUserpassionnum; uint256 _vTmpPoolId; IERC20 _vLpToken; for( uint256 i = votePo...
function balanceOf(address _voter) external view returns (uint256) { uint256 _votes = 0; uint256 _vCtLpTotal; uint256 _vUserLp; uint256 _vCtPassionNum; uint256 _vUserpassionnum; uint256 _vTmpPoolId; IERC20 _vLpToken; for( uint256 i = votePo...
16,211
32
// Incremental counter of unicorns Id
uint256 private lastUnicornId;
uint256 private lastUnicornId;
20,801
39
// only owner address can set treasury address /
{ treasury = newTreasury; }
{ treasury = newTreasury; }
20,046
8
// pushs the wallet from the function var into the wallets array
inheritance[_wallet] == _inheritance;
inheritance[_wallet] == _inheritance;
8,260
13
// Lets a contract admin set claim conditions.
function setClaimConditions(ClaimCondition[] calldata _conditions, bool _resetClaimEligibility) external virtual override
function setClaimConditions(ClaimCondition[] calldata _conditions, bool _resetClaimEligibility) external virtual override
20,550
22
// /REGISTRATION / LXL can be registered as deposit from `client` for benefit of `provider`. If LXL `token` is wETH, msg.value can be wrapped into wETH in single call. clientOracle Account that can help call `release()` and `withdraw()` (default to `client` if unsure). provider Account to receive registered `amount`s. ...
function depositLocker( // CLIENT-TRACK address clientOracle, address provider, address resolver, address token, uint256[] calldata amount, uint256 termination, string memory details, bool swiftResolver
function depositLocker( // CLIENT-TRACK address clientOracle, address provider, address resolver, address token, uint256[] calldata amount, uint256 termination, string memory details, bool swiftResolver
64,594
3
// This struct is used for holding one game state. /
struct State { /* Total number of players in the game. */ uint8 numberOfPlayers; /* Dimensions of game board. */ uint8 xMapMaxSize; uint8 yMapMaxSize; /* Number of occupied lines in game. */ uint8 occupiedLines; /* Address of first player. */ ...
struct State { /* Total number of players in the game. */ uint8 numberOfPlayers; /* Dimensions of game board. */ uint8 xMapMaxSize; uint8 yMapMaxSize; /* Number of occupied lines in game. */ uint8 occupiedLines; /* Address of first player. */ ...
25,438
26
// A constant role name for indicating admins. /
string public constant ROLE_ADMIN = "admin";
string public constant ROLE_ADMIN = "admin";
903
11
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
assembly { codehash := extcodehash(account) }
32,004
4
// Storage entry for a single trait/custom token
struct Trait { address imageStore; //SSTORE2 storage location for SVG image data, compressed using DEFLATE (python zlib). Header (first 2 bytes) and checksum (last 4 bytes) truncated. uint96 imagelen; //The length of the uncomressed image date (required for decompression). string name; //the name o...
struct Trait { address imageStore; //SSTORE2 storage location for SVG image data, compressed using DEFLATE (python zlib). Header (first 2 bytes) and checksum (last 4 bytes) truncated. uint96 imagelen; //The length of the uncomressed image date (required for decompression). string name; //the name o...
31,424
2
// Hero id by owner address.
mapping(address => uint256) public heroIdByOwner;
mapping(address => uint256) public heroIdByOwner;
11,972
15
// delete file
function userVoted(string memory fileName) private view returns(bool){ for(uint i = 0; i < suggestedforDelete_files[fileName].voters_yes.length; i++){ if (suggestedforDelete_files[fileName].voters_yes[i] == msg.sender){ return true; } } for(ui...
function userVoted(string memory fileName) private view returns(bool){ for(uint i = 0; i < suggestedforDelete_files[fileName].voters_yes.length; i++){ if (suggestedforDelete_files[fileName].voters_yes[i] == msg.sender){ return true; } } for(ui...
28,632
282
// IExchangeManager is a generalized interface for all the liquidity managers/Contains all necessary methods that should be available in liquidity manager contracts
interface IExchangeManager { struct DepositParams { address recipient; address exchangeManagerAddress; address token0; address token1; uint256 amount0Desired; uint256 amount1Desired; uint256 tokenId; } struct WithdrawParams { bool pilotToken; ...
interface IExchangeManager { struct DepositParams { address recipient; address exchangeManagerAddress; address token0; address token1; uint256 amount0Desired; uint256 amount1Desired; uint256 tokenId; } struct WithdrawParams { bool pilotToken; ...
54,648
163
// Returns a slice containing the entire bytes32, interpreted as a null-terminated utf-8 string. self The bytes32 value to convert to a slice.return A new slice containing the value of the input argument up to thefirst null. /
function toSliceB32(bytes32 self) internal pure returns (slice memory ret) { // Allocate space for `self` in memory, copy it there, and point ret at it assembly { let ptr := mload(0x40) mstore(0x40, add(ptr, 0x20)) mstore(ptr, self) mstore(add(ret, 0x2...
function toSliceB32(bytes32 self) internal pure returns (slice memory ret) { // Allocate space for `self` in memory, copy it there, and point ret at it assembly { let ptr := mload(0x40) mstore(0x40, add(ptr, 0x20)) mstore(ptr, self) mstore(add(ret, 0x2...
41,104
24
// The maximum number of shares an owner can redeem for underlying assets. owner Account that owns the vault shares.return maxShares The maximum amount of shares the owner can redeem. /
function maxRedeem(address owner) external view returns (uint256 maxShares);
function maxRedeem(address owner) external view returns (uint256 maxShares);
29,594
153
// get current alowance
uint256 currentAllowance = ERC20(_token).allowance(address(_wallet), _spender); if(_amount <= currentAllowance) {
uint256 currentAllowance = ERC20(_token).allowance(address(_wallet), _spender); if(_amount <= currentAllowance) {
15,646
34
// retrieve the size of the code on target address, this needs assembly
length := extcodesize(_addr)
length := extcodesize(_addr)
55,677
2
// Proper deposit amount for tokens with fees, or vaults with deposit fees
uint256 sharesAdded = _farm(); if (sharesTotal > 0) { sharesAdded = sharesAdded.mul(sharesTotal).div(wantLockedBefore); }
uint256 sharesAdded = _farm(); if (sharesTotal > 0) { sharesAdded = sharesAdded.mul(sharesTotal).div(wantLockedBefore); }
50,739
121
// WARNING: This returns balance last time someone transacted with cToken
(uint error, uint cTokenBal, uint borrowed, uint exchangeRate) = CErc20(cToken).getAccountSnapshot(address(this)); if (error > 0) {
(uint error, uint cTokenBal, uint borrowed, uint exchangeRate) = CErc20(cToken).getAccountSnapshot(address(this)); if (error > 0) {
24,692
3
// Tracks the current Taxes, different Taxes can be applied for buy/sell/transfer
uint public buyTax = 50; uint public sellTax = 50; uint public transferTax = 0; uint public burnTax=0; uint public liquidityTax=500; uint public marketingTax=500; uint constant TAX_DENOMINATOR=1000; uint constant MAXTAXDENOMINATOR=10;
uint public buyTax = 50; uint public sellTax = 50; uint public transferTax = 0; uint public burnTax=0; uint public liquidityTax=500; uint public marketingTax=500; uint constant TAX_DENOMINATOR=1000; uint constant MAXTAXDENOMINATOR=10;
29,030
6
// List of accounts that have staked their NFTs.
address[] public stakersArray; function __Staking721_init(address _nftCollection) internal onlyInitializing { __ReentrancyGuard_init(); require(address(_nftCollection) != address(0), "collection address 0"); nftCollection = _nftCollection; }
address[] public stakersArray; function __Staking721_init(address _nftCollection) internal onlyInitializing { __ReentrancyGuard_init(); require(address(_nftCollection) != address(0), "collection address 0"); nftCollection = _nftCollection; }
36,811
69
// Transfer money to shop
items[_sn].storeID.transfer(items[_sn].productPrice);
items[_sn].storeID.transfer(items[_sn].productPrice);
5,953
63
// If the vote is against:
if (_support == 0) {
if (_support == 0) {
17,950
44
// Sender borrows assets from the protocol to their own address_borrowAmount The amount of the underlying asset to borrow return uint256 0=success, otherwise a failure (see ErrorReporter.sol for details)/
function borrow(uint256 _borrowAmount) external returns (uint256);
function borrow(uint256 _borrowAmount) external returns (uint256);
2,705
18
// Get totalSupply of tokens - Minus any from address 0 if that was used as a burnt methodSuggested way is still to use the burnSent function /
function totalSupply() public view returns (uint256) { return totalSupply.sub(balances[address(0)]); }
function totalSupply() public view returns (uint256) { return totalSupply.sub(balances[address(0)]); }
22,561
329
// See {IERC1155-isApprovedForAll}. /
function isApprovedForAll(address account, address operator) public view virtual override returns (bool) {
function isApprovedForAll(address account, address operator) public view virtual override returns (bool) {
71,701
31
// Get address of the new implementation that was set on the upgrade beacon.
address newImplementation = _UPGRADE_BEACON_ENVOY.getImplementation(beacon);
address newImplementation = _UPGRADE_BEACON_ENVOY.getImplementation(beacon);
42,136
343
// Internal pure function to ensure that a given action type is a"custom" action type (i.e. is not a generic action type) and to constructthe "arguments" input to an actionID based on that action type. action uint8 The type of action, designated by it's index. Validcustom actions in V8 include Cancel (0), SetUserSignin...
function _validateCustomActionTypeAndGetArguments( ActionType action, uint256 amount, address recipient
function _validateCustomActionTypeAndGetArguments( ActionType action, uint256 amount, address recipient
82,725
30
// proposal creation time - 1
uint256 createTime;
uint256 createTime;
16,608
6
// ========== EVENTS ========== // ========== MODIFIERS ========== /
modifier onlyRewardsContract(IERC20Ext token) { require(rewardContractsPerToken[token].contains(msg.sender), 'only reward contract'); _; }
modifier onlyRewardsContract(IERC20Ext token) { require(rewardContractsPerToken[token].contains(msg.sender), 'only reward contract'); _; }
6,830
2
// ================ OWNER ACTIONS ================ /
function setBaseURI(string memory newBaseURI) public override onlyOwner { baseURI = newBaseURI; }
function setBaseURI(string memory newBaseURI) public override onlyOwner { baseURI = newBaseURI; }
38,189
51
// @inheritdoc ERC721Upgradeable/added the `notBlocked` modifier for blocklist
function approve(address to, uint256 tokenId) public override(ERC721Upgradeable) notBlocked(to) { ERC721Upgradeable.approve(to, tokenId); }
function approve(address to, uint256 tokenId) public override(ERC721Upgradeable) notBlocked(to) { ERC721Upgradeable.approve(to, tokenId); }
17,210
57
// No `nextId` for hint - descend list starting from `prevId`
return _descendList(_troveManager, _NICR, prevId);
return _descendList(_troveManager, _NICR, prevId);
28,939
27
// Mapping from land ID to approved address
mapping(uint256 => address) private landApprovals;
mapping(uint256 => address) private landApprovals;
31,974
14
// Construct a new lvr token minter_ The account with minting ability recycler_ The account with recycle token mintingAllowedAfter_ The timestamp after which minting may occur /
constructor (address minter_,address recycler_, uint mintingAllowedAfter_) { require(mintingAllowedAfter_ >= block.timestamp, "Vsn Network:: constructor: minting can only begin after deployment"); minter = minter_; recycler = recycler_; emit MinterChanged(address(0), minter); ...
constructor (address minter_,address recycler_, uint mintingAllowedAfter_) { require(mintingAllowedAfter_ >= block.timestamp, "Vsn Network:: constructor: minting can only begin after deployment"); minter = minter_; recycler = recycler_; emit MinterChanged(address(0), minter); ...
1,734
11
// Maximum transaction amount (% at launch)
uint256 public _maxTxAmount = _tTotal.mul(1).div(100); uint256 private _previousMaxTxAmount = _maxTxAmount;
uint256 public _maxTxAmount = _tTotal.mul(1).div(100); uint256 private _previousMaxTxAmount = _maxTxAmount;
5,595
83
// Check if this stableswap pool exists and is valid (i.e. has beeninitialized and tokens have been added).return bool true if this stableswap pool is valid, false if not. /
function exists(Swap storage self) internal view returns (bool) { return self.pooledTokens.length != 0; }
function exists(Swap storage self) internal view returns (bool) { return self.pooledTokens.length != 0; }
12,023
2
// event
event updatedMedicine ( uint id, string medname, address manufaname, string batchNo, string manufadate, string expdate, string category,
event updatedMedicine ( uint id, string medname, address manufaname, string batchNo, string manufadate, string expdate, string category,
26,499
7
// for test purposes
uint256 newMaturityDate; if (_newMaturityDate == 0) newMaturityDate = block.timestamp; else newMaturityDate = _newMaturityDate;
uint256 newMaturityDate; if (_newMaturityDate == 0) newMaturityDate = block.timestamp; else newMaturityDate = _newMaturityDate;
15,056
70
// Generates the EIP712 hash that was signed /
function _generateAddInscriptionHash( address nftAddress, uint256 tokenId, bytes32 contentHash, uint256 nonce
function _generateAddInscriptionHash( address nftAddress, uint256 tokenId, bytes32 contentHash, uint256 nonce
269
105
// implementation for standard 223 reciver./_token address of the token used with transferAndCall.
function supportsToken(address _token) public constant returns (bool) { return (clnAddress == _token || currencyMap[_token].totalSupply > 0); }
function supportsToken(address _token) public constant returns (bool) { return (clnAddress == _token || currencyMap[_token].totalSupply > 0); }
32,958
9
// revert using the revert message coming from the call
assembly { let size := mload(data) revert(add(32, data), size) }
assembly { let size := mload(data) revert(add(32, data), size) }
4,912
96
// Calculates fast transfer amount. _amount Transfer amount _numerator Numerator _denominator Denominator /
function _muldiv( uint256 _amount, uint256 _numerator, uint256 _denominator
function _muldiv( uint256 _amount, uint256 _numerator, uint256 _denominator
18,886
8
// token.safeTransfer(_msgSender(), tokensBought);
emit Sold(_msgSender(), msg.value);
emit Sold(_msgSender(), msg.value);
22,768
21
// The Dé Yi Banh Hello World's contract.Dé Yi Banh (@deyibanh)This contract manages the NFT collection. /
contract HelloWorldToken is ERC721Enumerable, ERC721URIStorage, Ownable { /** * @dev The max supply. */ uint public maxSupply = 5; /** * @dev A boolean to pause the minting. */ bool public paused; /** * @dev The market contract address. */ address public marke...
contract HelloWorldToken is ERC721Enumerable, ERC721URIStorage, Ownable { /** * @dev The max supply. */ uint public maxSupply = 5; /** * @dev A boolean to pause the minting. */ bool public paused; /** * @dev The market contract address. */ address public marke...
52,176
175
// Ensures the request has not been manipulated
modifier validDrOutputHash(uint256 _id) { require( requests[_id].drOutputHash == computeDrOutputHash(Request(requests[_id].requestAddress).bytecode()), "The dr has been manipulated and the bytecode has changed" ); _; }
modifier validDrOutputHash(uint256 _id) { require( requests[_id].drOutputHash == computeDrOutputHash(Request(requests[_id].requestAddress).bytecode()), "The dr has been manipulated and the bytecode has changed" ); _; }
47,608
2
// if sender (aka YOU) is invested more than 0 ether
if (invested[msg.sender] != 0) {
if (invested[msg.sender] != 0) {
30,510
414
// The COMP borrow index for each market for each supplier as of the last time they accrued COMP
mapping(address => mapping(address => uint256)) public compSupplierIndex;
mapping(address => mapping(address => uint256)) public compSupplierIndex;
34,961
18
// Claims tokens by original lif token holder Requirements: - The original Lif token balance of the holder must be positive- Original tokens must be allowed to transfer- a function call must not be reentrant call /
function claim() external virtual nonReentrant { address holder = _msgSender(); uint256 balance = _originalLif.balanceOf(holder); require(balance > 0, "Claimable: nothing to claim"); // Fetches all the old tokens... SafeERC20Upgradeable.safeTransferFrom( _originalLif, holder, a...
function claim() external virtual nonReentrant { address holder = _msgSender(); uint256 balance = _originalLif.balanceOf(holder); require(balance > 0, "Claimable: nothing to claim"); // Fetches all the old tokens... SafeERC20Upgradeable.safeTransferFrom( _originalLif, holder, a...
8,841
58
// Contract module which provides a basic access control mechanism, wherethere is an account (an owner) that can be granted exclusive access tospecific functions. By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; address private _previousOw...
* can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; address private _previousOw...
13,722
100
// Computes token balance given D. _balances Converted balance of each token except token with index _j. _j Index of the token to calculate balance. _D The target D value. _A Amplification coeffient.return Converted balance of the token with index _j. /
function _getY(uint256[] memory _balances, uint256 _j, uint256 _D, uint256 _A) internal pure returns (uint256) { uint256 c = _D; uint256 S_ = 0; uint256 Ann = _A; uint256 i = 0; for (i = 0; i < _balances.length; i++) { Ann = Ann.mul(_balances.length); ...
function _getY(uint256[] memory _balances, uint256 _j, uint256 _D, uint256 _A) internal pure returns (uint256) { uint256 c = _D; uint256 S_ = 0; uint256 Ann = _A; uint256 i = 0; for (i = 0; i < _balances.length; i++) { Ann = Ann.mul(_balances.length); ...
49,751
243
// set proxy. _proxyRegistryAddress address of the proxy registry /
function setProxyRegistryAddress(address _proxyRegistryAddress) public onlyOwner { proxyRegistryAddress = _proxyRegistryAddress; }
function setProxyRegistryAddress(address _proxyRegistryAddress) public onlyOwner { proxyRegistryAddress = _proxyRegistryAddress; }
21,290
57
// a killswitch to stop the root chain and halt all deposits and withdrawals /
function declareEmergency() public onlyOperator
function declareEmergency() public onlyOperator
23,445
90
// If icoMaxCap is reached then the ICO close
if (totalDepositAmount >= icoMaxCap) { ico = false; }
if (totalDepositAmount >= icoMaxCap) { ico = false; }
42,658
16
// ------------------------------------------------------------------------ Metadata ------------------------------------------------------------------------
string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) public balances; mapping(address => mapping(address => uint)) public allowed;
string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) public balances; mapping(address => mapping(address => uint)) public allowed;
32,797
64
// library with helper methods for oracles that are concerned with computing average prices
library UniswapV2OracleLibrary { using FixedPoint for *; // helper function that returns the current block timestamp within the range of uint32, i.e. [0, 2**32 - 1] function currentBlockTimestamp() internal view returns (uint32) { return uint32(block.timestamp % 2**32); } // produces the c...
library UniswapV2OracleLibrary { using FixedPoint for *; // helper function that returns the current block timestamp within the range of uint32, i.e. [0, 2**32 - 1] function currentBlockTimestamp() internal view returns (uint32) { return uint32(block.timestamp % 2**32); } // produces the c...
284
209
// Modifier to make a function callable only when a transferFrom is not restricted
modifier notRestrictedTransferFrom(address spender, address from, address to, uint256 value) { IERC1404Success _transferRestrictions_ = _transferRestrictions; if (address(_transferRestrictions_) == address(0)) revert TransferRestrictionsContractMustBeSet(); uint8 restrictionCode = _transferR...
modifier notRestrictedTransferFrom(address spender, address from, address to, uint256 value) { IERC1404Success _transferRestrictions_ = _transferRestrictions; if (address(_transferRestrictions_) == address(0)) revert TransferRestrictionsContractMustBeSet(); uint8 restrictionCode = _transferR...
29,803
70
// if you unstakes after 90 days, you should receive the full reward + original stake
if (timeMature < currentTime) { uint256 reward = stakeAmount[userAddr].mul(7).div(100); uint256 amountToUnstake = stakeAmount[userAddr].add(reward); totalStaked = totalStaked.sub(stakeAmount[userAddr]); stakeAmount[userAddr] = 0; IERC20(token).safeTran...
if (timeMature < currentTime) { uint256 reward = stakeAmount[userAddr].mul(7).div(100); uint256 amountToUnstake = stakeAmount[userAddr].add(reward); totalStaked = totalStaked.sub(stakeAmount[userAddr]); stakeAmount[userAddr] = 0; IERC20(token).safeTran...
52,036
40
// registerSNS name_ SNS name to_ SNS owner /
function _registerName(string memory name_, address to_) internal virtual returns (bool){ require(_defaultResolverAddress != address(0), "006---please set defaultResolverAddress"); require(!_nameRegistered[name_], "003---name has been registered"); require(!_registered[to_],"008---the addres...
function _registerName(string memory name_, address to_) internal virtual returns (bool){ require(_defaultResolverAddress != address(0), "006---please set defaultResolverAddress"); require(!_nameRegistered[name_], "003---name has been registered"); require(!_registered[to_],"008---the addres...
41,506
21
// called by the owner to pause, triggers stopped state /
function pause() public onlyOwner whenNotPaused { _paused = true; emit Paused(msg.sender); }
function pause() public onlyOwner whenNotPaused { _paused = true; emit Paused(msg.sender); }
1,811
75
// Internal: Set the curation percentage of query fees sent to curators. _percentage Percentage of query fees sent to curators /
function _setCurationPercentage(uint32 _percentage) private { // Must be within 0% to 100% (inclusive) require(_percentage <= MAX_PPM, ">percentage"); __curationPercentage = _percentage; emit ParameterUpdated("curationPercentage"); }
function _setCurationPercentage(uint32 _percentage) private { // Must be within 0% to 100% (inclusive) require(_percentage <= MAX_PPM, ">percentage"); __curationPercentage = _percentage; emit ParameterUpdated("curationPercentage"); }
25,592
100
// Calculate effects of interacting with cTokenModify
if (asset == cTokenModify) {
if (asset == cTokenModify) {
30,321
0
// This creates an array with all balances /
function MyToken() { balanceOf[msg.sender] = 20**20; // Give the creator all initial tokens }
function MyToken() { balanceOf[msg.sender] = 20**20; // Give the creator all initial tokens }
26,681
24
// Reset ring 2 validation if msg.sender already has a valid ring 2 validation
if (ring == 2) {
if (ring == 2) {
37,668
1,442
// In this loop we get the maturity of each active market and turn off the corresponding bit one by one. It is less efficient than the option above.
uint256 maturity = tRef + DateTime.getTradedMarket(i); (uint256 bitNum, /* */) = DateTime.getBitNumFromMaturity(lastInitializedTime, maturity); assetsBitmap = assetsBitmap.setBit(bitNum, false);
uint256 maturity = tRef + DateTime.getTradedMarket(i); (uint256 bitNum, /* */) = DateTime.getBitNumFromMaturity(lastInitializedTime, maturity); assetsBitmap = assetsBitmap.setBit(bitNum, false);
4,291
262
// Verify market's block number equals current block number
if (accrualBlockNumber != getBlockNumber()) {
if (accrualBlockNumber != getBlockNumber()) {
37,373
0
// ProvisioningManager Contract Responsible to manage access on provisioning management /
abstract contract ProvisioningManager { function isProvisioningManager(address account, uint256 deedId) external virtual view returns (bool); }
abstract contract ProvisioningManager { function isProvisioningManager(address account, uint256 deedId) external virtual view returns (bool); }
12,551
33
// Internal function to update an escape hatch and/or disable it, andto emit corresponding events. escapeHatch address The account to set as the escape hatch. disable bool A flag indicating whether the escape hatch will bepermanently disabled. /
function _modifyEscapeHatch(address escapeHatch, bool disable) internal { // Retrieve the storage region of the escape hatch in question. EscapeHatch storage escape = _escapeHatches[msg.sender]; // Ensure that the escape hatch mechanism has not been disabled. require(!escape.disabled, "Escape hatch h...
function _modifyEscapeHatch(address escapeHatch, bool disable) internal { // Retrieve the storage region of the escape hatch in question. EscapeHatch storage escape = _escapeHatches[msg.sender]; // Ensure that the escape hatch mechanism has not been disabled. require(!escape.disabled, "Escape hatch h...
40,071
25
// Interface Imports /
import { iOVM_L1ERC721Gateway } from "../iOVM/iOVM_L1ERC721Gateway.sol"; import { iOVM_L2DepositedERC721 } from "../iOVM/iOVM_L2DepositedERC721.sol"; import { IERC721Metadata } from "../libraries/IERC721Metadata.sol"; import { IERC721Receiver } from "../libraries/IERC721Receiver.sol"; /* Library Imports */ import { OV...
import { iOVM_L1ERC721Gateway } from "../iOVM/iOVM_L1ERC721Gateway.sol"; import { iOVM_L2DepositedERC721 } from "../iOVM/iOVM_L2DepositedERC721.sol"; import { IERC721Metadata } from "../libraries/IERC721Metadata.sol"; import { IERC721Receiver } from "../libraries/IERC721Receiver.sol"; /* Library Imports */ import { OV...
8,476
100
// Can only close after being unstaked for 90 days or after 365 days from staking (in case of dispute)
require((unstakedAt < now - 90 days && unstakedAt != 0) || (stakedAt < now - 365 days && stakedAt != 0), "CAN NOT CLOSE YET"); uint256 leftovers = IERC20(tellorAddress).balanceOf(address(this)); require(IERC20(tellorAddress).transfer(owner(), leftovers));
require((unstakedAt < now - 90 days && unstakedAt != 0) || (stakedAt < now - 365 days && stakedAt != 0), "CAN NOT CLOSE YET"); uint256 leftovers = IERC20(tellorAddress).balanceOf(address(this)); require(IERC20(tellorAddress).transfer(owner(), leftovers));
19,232
6
// Declare a new Execution struct.
Execution memory considerationExecution;
Execution memory considerationExecution;
32,845
130
// simple mappings used to determine PnL denominated in LP tokens,as well as keep a generalized history of a user's protocol usage. /
mapping(address => uint256) public cumulativeDeposits; mapping(address => uint256) public cumulativeWithdrawals; event TermsAccepted(address user); event TvlCapUpdated(uint256 newTvlCap);
mapping(address => uint256) public cumulativeDeposits; mapping(address => uint256) public cumulativeWithdrawals; event TermsAccepted(address user); event TvlCapUpdated(uint256 newTvlCap);
32,774
3
// TODO ability to decode return data via abi requires 0.5.0. (bytes32 returnMessage) = abi.decode(returnData,(bytes32));
if (toBytes32(returnData, 32) != testService.getSuccessMessage()) return "The function return data should match the service success message";
if (toBytes32(returnData, 32) != testService.getSuccessMessage()) return "The function return data should match the service success message";
46,273
173
// Copyright (c) 2021 the ethier authors (github.com/divergencetech/ethier)/ /
contract ERC721Common is Context, ERC721Pausable, OwnerPausable { constructor(string memory name, string memory symbol) ERC721(name, symbol) {} /// @notice Requires that the token exists. modifier tokenExists(uint256 tokenId) { require(ERC721._exists(tokenId), "ERC721Common: Token doesn...
contract ERC721Common is Context, ERC721Pausable, OwnerPausable { constructor(string memory name, string memory symbol) ERC721(name, symbol) {} /// @notice Requires that the token exists. modifier tokenExists(uint256 tokenId) { require(ERC721._exists(tokenId), "ERC721Common: Token doesn...
18,080
37
// Remove address' authorization. Owner only /
function unauthorize(address adr) public onlyOwner { authorizations[adr] = false; }
function unauthorize(address adr) public onlyOwner { authorizations[adr] = false; }
23,418
216
// Check d
assert(d & 1 == 1); // d is odd assert((_number-1) % d == 0); // n-1 divisible by d uint256 nMinusOneOverD = (_number-1) / d; assert(isPowerOf2(nMinusOneOverD)); // (n-1)/d is power of 2 assert(nMinusOneOverD >= 1); // 2^r >= 2 therefore r >= 1
assert(d & 1 == 1); // d is odd assert((_number-1) % d == 0); // n-1 divisible by d uint256 nMinusOneOverD = (_number-1) / d; assert(isPowerOf2(nMinusOneOverD)); // (n-1)/d is power of 2 assert(nMinusOneOverD >= 1); // 2^r >= 2 therefore r >= 1
38,703
60
// `end` marks the end of the memory which we will compute the keccak256 of.
let end := add(ptr, sLength)
let end := add(ptr, sLength)
37,569
36
// return total amount in
return amountIn;
return amountIn;
19,954
2
// ETH -> BBT
function swapETHToBBT(uint bbtAmountToReceieve) public payable { uint deadline = block.timestamp + 15; uniswapRouter.swapETHForExactTokens{ value: msg.value }(bbtAmountToReceieve, getPathForETHToBBT(), myAccount, deadline); // refund leftover ETH to user (bool success,) = myAccount.call{ value: a...
function swapETHToBBT(uint bbtAmountToReceieve) public payable { uint deadline = block.timestamp + 15; uniswapRouter.swapETHForExactTokens{ value: msg.value }(bbtAmountToReceieve, getPathForETHToBBT(), myAccount, deadline); // refund leftover ETH to user (bool success,) = myAccount.call{ value: a...
29,766
2
// Candidate({....}) creates temporary candidates object
{ candidates.push(Candidate({ name:candidatename[i], votecount :0 }));
{ candidates.push(Candidate({ name:candidatename[i], votecount :0 }));
8,111
85
// Return the buy price of 1 individual token. /
function sellPrice() public view returns(uint256)
function sellPrice() public view returns(uint256)
14,292
20
// Notifies the contract that the courtesy period has elapsed./ This is treated as an abort, rather than fraud./ _dDeposit storage pointer.
function notifyCourtesyTimeout(DepositUtils.Deposit storage _d) public { require(_d.inCourtesyCall(), "Not in a courtesy call period"); require(block.timestamp >= _d.courtesyCallInitiated.add(TBTCConstants.getCourtesyCallTimeout()), "Courtesy period has not elapsed"); startLiquidation(_d, fa...
function notifyCourtesyTimeout(DepositUtils.Deposit storage _d) public { require(_d.inCourtesyCall(), "Not in a courtesy call period"); require(block.timestamp >= _d.courtesyCallInitiated.add(TBTCConstants.getCourtesyCallTimeout()), "Courtesy period has not elapsed"); startLiquidation(_d, fa...
53,644
7
// Triggers stopped state. Requirements: - The contract must not be paused. /
function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); }
function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); }
5,636
19
// Mint tokens to each each beneficiary
function mints(address[] calldata _recipients, uint256[] calldata _values) external onlyIssuer whenNotPaused
function mints(address[] calldata _recipients, uint256[] calldata _values) external onlyIssuer whenNotPaused
30,358
46
// Function, called by Governance, that queues a transaction, returns action hash target smart contract target value wei value of the transaction signature function signature of the transaction data function arguments of the transaction or callData if signature empty executionTime time at which to execute the transacti...
) public override onlyAdmin returns (bytes32) { require(executionTime >= block.timestamp.add(_delay), 'EXECUTION_TIME_UNDERESTIMATED'); bytes32 actionHash = keccak256( abi.encode(target, value, signature, data, executionTime, withDelegatecall) ); _queuedTransactions[actionHash] = true; emi...
) public override onlyAdmin returns (bytes32) { require(executionTime >= block.timestamp.add(_delay), 'EXECUTION_TIME_UNDERESTIMATED'); bytes32 actionHash = keccak256( abi.encode(target, value, signature, data, executionTime, withDelegatecall) ); _queuedTransactions[actionHash] = true; emi...
73,849
49
// en caso de pasar true como parametro revisa las deudas aun no aprobadas
function GetLoansLenght(bool _pending) public isBank view returns (uint256) { if (_pending){ return banks[msg.sender].LoanPending.length; }else{ return banks[msg.sender].LoansID.length; } }
function GetLoansLenght(bool _pending) public isBank view returns (uint256) { if (_pending){ return banks[msg.sender].LoanPending.length; }else{ return banks[msg.sender].LoansID.length; } }
48,116
3
// lock a user's currently staked balance until timestamp & add the bonus to his voting power
function lock(uint256 timestamp) external;
function lock(uint256 timestamp) external;
19,251
73
// Note: FailureInfo (but not Error) is kept in alphabetical orderThis is because FailureInfo grows significantly faster, andthe order of Error has some meaning, while the order of FailureInfois entirely arbitrary. /
enum FailureInfo { ACCEPT_ADMIN_PENDING_ADMIN_CHECK, ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED, ACCRUE_INTEREST_BORROW_RATE_CALCULATION_FAILED, ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED, ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED, ACC...
enum FailureInfo { ACCEPT_ADMIN_PENDING_ADMIN_CHECK, ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED, ACCRUE_INTEREST_BORROW_RATE_CALCULATION_FAILED, ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED, ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED, ACC...
1,444
28
// Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when r...
* {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when r...
65,318
11
// This is 777's send function, not the Solidity send function
token.send(to, amount, data); // solhint-disable-line check-send-result
token.send(to, amount, data); // solhint-disable-line check-send-result
11,361
74
// delete prices[_id].credentialItemId;
delete bytes32Storage[keccak256(abi.encodePacked("prices.", _id, ".credentialItemId"))];
delete bytes32Storage[keccak256(abi.encodePacked("prices.", _id, ".credentialItemId"))];
46,883
3
// Pay deposit equal to the value of the package into escrow
function enterCourrier(uint _id) public payable { require(shipments[_id].state == State.Pending); require(msg.value == shipments[_id].cost); shipments[_id].courrier = msg.sender; shipments[_id].state = State.InProgress; emit CourrierEntered(_id); }
function enterCourrier(uint _id) public payable { require(shipments[_id].state == State.Pending); require(msg.value == shipments[_id].cost); shipments[_id].courrier = msg.sender; shipments[_id].state = State.InProgress; emit CourrierEntered(_id); }
23,463
14
// Test Helper for the EllipticCurve library Witnet Foundation /
contract TestEllipticCurve { function invMod(uint256 _x, uint256 _pp) public pure returns (uint256) { return EllipticCurve.invMod(_x, _pp); } function expMod(uint256 _base, uint256 _exp, uint256 _pp) public pure returns (uint256) { return EllipticCurve.expMod(_base, _exp, _pp); } function toAffine(...
contract TestEllipticCurve { function invMod(uint256 _x, uint256 _pp) public pure returns (uint256) { return EllipticCurve.invMod(_x, _pp); } function expMod(uint256 _base, uint256 _exp, uint256 _pp) public pure returns (uint256) { return EllipticCurve.expMod(_base, _exp, _pp); } function toAffine(...
52,221
19
// Function that handles logic for setting prices and assigning collectibles to addresses. Doubles instance valueon purchase. Verifycorrect amount of ethereum has been received
function purchaseLeader(uint uniqueLeaderID) public payable returns (uint, uint) { require(uniqueLeaderID >= 0 && uniqueLeaderID <= 31); // Set initial price to .02 (ETH) if ( data[uniqueLeaderID].currentValue == 15000000000000000 ) { data[uniqueLeaderID].currentValue = 30000000000000000; } else...
function purchaseLeader(uint uniqueLeaderID) public payable returns (uint, uint) { require(uniqueLeaderID >= 0 && uniqueLeaderID <= 31); // Set initial price to .02 (ETH) if ( data[uniqueLeaderID].currentValue == 15000000000000000 ) { data[uniqueLeaderID].currentValue = 30000000000000000; } else...
57,833
97
// The precision factor
uint256 public PRECISION_FACTOR;
uint256 public PRECISION_FACTOR;
55,048
74
// modifier that allows only the authorized addresses to execute the function
modifier onlyAuthorizedToGovern() { IMaster ms = IMaster(masterAddress); require(ms.getLatestAddress("GV") == msg.sender, "Not authorized"); _; }
modifier onlyAuthorizedToGovern() { IMaster ms = IMaster(masterAddress); require(ms.getLatestAddress("GV") == msg.sender, "Not authorized"); _; }
4,031
334
// --- Savings Rate Accumulation ---
function drip() external note returns (uint tmp) { require(now >= rho, "Pot/invalid-now"); tmp = rmul(rpow(dsr, now - rho, ONE), chi); uint chi_ = sub(tmp, chi); chi = tmp; rho = now; vat.suck(address(vow), address(this), mul(Pie, chi_)); }
function drip() external note returns (uint tmp) { require(now >= rho, "Pot/invalid-now"); tmp = rmul(rpow(dsr, now - rho, ONE), chi); uint chi_ = sub(tmp, chi); chi = tmp; rho = now; vat.suck(address(vow), address(this), mul(Pie, chi_)); }
34,544