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
27
// Transfer user's NFTs back to user
stakingToken721.safeTransferFrom(address(this), msg.sender, tokenIds[i]);
stakingToken721.safeTransferFrom(address(this), msg.sender, tokenIds[i]);
2,467
46
// Generates newly minted ACO tokens and sends them to a given address. This function can only be called by the owners of the ICO contract during the minting period. _to The address to mint new tokens to. _amount The amount of tokens to mint./
function issueBounty(address _to, uint256 _amount) public onlyOwners { require(_to != 0x0 && _amount > 0); ACO_Token.mint(_to, _amount); }
function issueBounty(address _to, uint256 _amount) public onlyOwners { require(_to != 0x0 && _amount > 0); ACO_Token.mint(_to, _amount); }
43,181
9
// Calculate the reward amount for each fixed address and the remainder
uint256 remainder = totalFixedAddressPart % fixedAddressesLength; uint256 rewardPerAddress = totalFixedAddressPart / fixedAddressesLength; for (uint i = 0; i < fixedAddressesLength; i++) { address fixedAddress = _WHAPcoinContract.get_FixedAddressAt(i); if(fixedAddress == _WHAPcoinContract._ProjectOwner()){
uint256 remainder = totalFixedAddressPart % fixedAddressesLength; uint256 rewardPerAddress = totalFixedAddressPart / fixedAddressesLength; for (uint i = 0; i < fixedAddressesLength; i++) { address fixedAddress = _WHAPcoinContract.get_FixedAddressAt(i); if(fixedAddress == _WHAPcoinContract._ProjectOwner()){
20,300
62
// LIBRARY FUNCTIONS
function quote(uint amountA, uint reserveA, uint reserveB) public pure virtual override returns (uint amountB) { return CorgiSLibrary.quote(amountA, reserveA, reserveB); }
function quote(uint amountA, uint reserveA, uint reserveB) public pure virtual override returns (uint amountB) { return CorgiSLibrary.quote(amountA, reserveA, reserveB); }
6,671
139
// TrueCAD This is the top-level ERC20 contract, but most of the interesting functionality isinherited - see the documentation on the corresponding contracts. /
contract TrueCAD is TrueCurrency { uint8 constant DECIMALS = 18; uint8 constant ROUNDING = 2; function decimals() public override pure returns (uint8) { return DECIMALS; } function rounding() public pure returns (uint8) { return ROUNDING; } function name() public override pure returns (string memory) { return "TrueCAD"; } function symbol() public override pure returns (string memory) { return "TCAD"; } }
contract TrueCAD is TrueCurrency { uint8 constant DECIMALS = 18; uint8 constant ROUNDING = 2; function decimals() public override pure returns (uint8) { return DECIMALS; } function rounding() public pure returns (uint8) { return ROUNDING; } function name() public override pure returns (string memory) { return "TrueCAD"; } function symbol() public override pure returns (string memory) { return "TCAD"; } }
46,003
10
// setting the address of nft owner to check the mapping of the address from tokenOwner at the tokenId
address owner = _tokenOwner[tokenId];
address owner = _tokenOwner[tokenId];
16,700
36
// owner > spender > allowance mapping.
mapping(address => mapping(address => uint256)) public allowance;
mapping(address => mapping(address => uint256)) public allowance;
5,349
74
// The sell amount taking the spread into account, ie: (1 - spread)sellAmount
FixidityLib.Fraction memory adjustedSellAmount = FixidityLib.fixed1().subtract(spread).multiply( FixidityLib.newFixed(sellAmount) );
FixidityLib.Fraction memory adjustedSellAmount = FixidityLib.fixed1().subtract(spread).multiply( FixidityLib.newFixed(sellAmount) );
24,640
78
// If n is even:
if mod(n, 2) {
if mod(n, 2) {
19,035
28
// Deal with lp last.
_collectFees(exitFees); _burnLp(inLpAfterExitFee);
_collectFees(exitFees); _burnLp(inLpAfterExitFee);
37,389
0
// Contract is already init, and cannot be initialized again./Selector 0xef34ca5c.
error AlreadyInit();
error AlreadyInit();
18,741
92
// Admin is set by owner first time, after that admin is super role and has permission to change owner/_admin Address of multisig that becomes admin
function setAdminByOwner(address _admin) public { require(msg.sender == owner); require(admin == address(0)); admin = _admin; }
function setAdminByOwner(address _admin) public { require(msg.sender == owner); require(admin == address(0)); admin = _admin; }
2,581
113
// requestOracleData is version 2, enabling multi-word responses
bytes4 constant private OPERATOR_REQUEST_SELECTOR = this.requestOracleData.selector; LinkTokenInterface internal immutable linkToken; mapping(bytes32 => Commitment) private sCommitments;
bytes4 constant private OPERATOR_REQUEST_SELECTOR = this.requestOracleData.selector; LinkTokenInterface internal immutable linkToken; mapping(bytes32 => Commitment) private sCommitments;
34,725
43
// This method is used to unstake all the amount of lp token.Note: It calls another internal "_unstake" method. See its description.Note: unstake lp token. /
function unstake() external whenNotPaused nonReentrant { _unstake(msg.sender); }
function unstake() external whenNotPaused nonReentrant { _unstake(msg.sender); }
38,238
64
// Check if the contract is indeed a token contract
require(token.totalSupply() > 0, "total supply zero"); controller = _controller;
require(token.totalSupply() > 0, "total supply zero"); controller = _controller;
17,753
22
// Allows to set the contract version./_version contract version
function setVersion(string memory _version) external override onlyRole(DEFAULT_ADMIN_ROLE)
function setVersion(string memory _version) external override onlyRole(DEFAULT_ADMIN_ROLE)
40,599
107
// Handle the approval of ERC1363 tokens Any ERC1363 smart contract calls this function on the recipientafter an `approve`. This function MAY throw to revert and reject theapproval. Return of other than the magic value MUST result in thetransaction being reverted.Note: the token contract address is always the message sender. sender address The address which called `approveAndCall` function amount uint256 The amount of tokens to be spent data bytes Additional data with no specified formatreturn `bytes4(keccak256("onApprovalReceived(address,uint256,bytes)"))` unless throwing /
function onApprovalReceived( address sender, uint256 amount, bytes calldata data ) external returns (bytes4);
function onApprovalReceived( address sender, uint256 amount, bytes calldata data ) external returns (bytes4);
22,705
98
// e.g. weeks = 1= 173e15 - 25e15 = 148e15 or 14.8% e.g. weeks = 10 =55e15 - 25e15 = 30e15 or 3% e.g. weeks = 26 =34e15 - 25e15 = 9e15 or 0.9%
_feeRate = _feeRate < 25e15 ? 0 : _feeRate - 25e15;
_feeRate = _feeRate < 25e15 ? 0 : _feeRate - 25e15;
63,115
2
// get all fees as array
function getFees() public view returns (uint256[] memory) { uint256[] memory fees = new uint256[](5); fees[0] = ListingAndFeesPrice; fees[1] = premiumFees; fees[2] = premiumDays; fees[3] = ownerPercentage; return fees; }
function getFees() public view returns (uint256[] memory) { uint256[] memory fees = new uint256[](5); fees[0] = ListingAndFeesPrice; fees[1] = premiumFees; fees[2] = premiumDays; fees[3] = ownerPercentage; return fees; }
11,469
17
// Harvests a given strategy on the provided controller This function ignores the timeout _controller The address of the controller _strategy The address of the strategy /
function harvest( IController _controller, address _strategy
function harvest( IController _controller, address _strategy
31,409
76
// Returns `true` if `account` has been granted `role`. /
function hasRole(bytes32 role, address account) public view override returns (bool) { return _roles[role].members[account]; }
function hasRole(bytes32 role, address account) public view override returns (bool) { return _roles[role].members[account]; }
989
12
// Returns total 'powah' supply.
function totalSupply() external view returns (uint256 total) { total = spell.balanceOf(address(sspell)) + spell.balanceOf(address(pair)) * 2; }
function totalSupply() external view returns (uint256 total) { total = spell.balanceOf(address(sspell)) + spell.balanceOf(address(pair)) * 2; }
22,977
30
// Fail for fungible tokens
if (mTokenType != MTokenType.ERC721_MTOKEN) { return uint(Error.MARKET_NOT_LISTED); }
if (mTokenType != MTokenType.ERC721_MTOKEN) { return uint(Error.MARKET_NOT_LISTED); }
38,874
95
// Burns a specific amount of tokens from the given address. Only the owner can call this function. account The address from which tokens will be burned. amount The amount of tokens to be burned. /
function burnFrom(address account, uint256 amount) public onlyOwner { _burn(account, amount); }
function burnFrom(address account, uint256 amount) public onlyOwner { _burn(account, amount); }
4,961
333
// The current implementation assumes that the volatility cannot exceed 1, and corresponding to this, when the calculated value exceeds 1, expressed as 0xFFFFFFFFFFFF
if (tmp > 0xFFFFFFFFFFFF) { tmp = 0xFFFFFFFFFFFF; }
if (tmp > 0xFFFFFFFFFFFF) { tmp = 0xFFFFFFFFFFFF; }
30,597
92
// LocalRemote ---------------- redeemLocal -> redeemLocalCheckOnRemote redeemLocalCallback <-
function redeemLocal( address _from, uint256 _amountLP, uint16 _dstChainId, uint256 _dstPoolId, bytes calldata _to ) external nonReentrant onlyRouter returns (uint256 amountSD) { require(_from != address(0x0), "Stargate: _from cannot be 0x0");
function redeemLocal( address _from, uint256 _amountLP, uint16 _dstChainId, uint256 _dstPoolId, bytes calldata _to ) external nonReentrant onlyRouter returns (uint256 amountSD) { require(_from != address(0x0), "Stargate: _from cannot be 0x0");
6,436
23
// Unlocks ERC721 behaviour, allowing for trading on third party platforms. /
function enableERC721 () onlyOwner() public { erc721Enabled = true; }
function enableERC721 () onlyOwner() public { erc721Enabled = true; }
18,622
194
// limit value of c and t to avoid overflow
require(cInPrecision < POWER_128, "validateParams: c is high"); require(tInPrecision < POWER_128, "validateParams: t is high");
require(cInPrecision < POWER_128, "validateParams: c is high"); require(tInPrecision < POWER_128, "validateParams: t is high");
13,878
234
// Returns if the `operator` is allowed to manage all of the assets of `owner`.
* See {setApprovalForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; }
* See {setApprovalForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; }
27,396
31
// It allows owner to manually initialize new contract implementation which supports IDLE distribution_newGovTokens : array of gov token addresses _protocolTokens : array of protocol tokens supported _wrappers : array of wrappers for protocol tokens _lastRebalancerAllocations : array of allocations _isRiskAdjusted : flag whether is risk adjusted or not /
function manualInitialize( address[] calldata _newGovTokens, address[] calldata _protocolTokens, address[] calldata _wrappers, uint256[] calldata _lastRebalancerAllocations, bool _isRiskAdjusted, address _cToken, address _aToken
function manualInitialize( address[] calldata _newGovTokens, address[] calldata _protocolTokens, address[] calldata _wrappers, uint256[] calldata _lastRebalancerAllocations, bool _isRiskAdjusted, address _cToken, address _aToken
46,688
66
// Event emitted when underlying is borrowed /
event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows);
event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows);
5,766
68
// Reset proposal + timestamp
if (_proposed != address(0)) { delete s.routerPermissionInfo.proposedRouterOwners[router]; }
if (_proposed != address(0)) { delete s.routerPermissionInfo.proposedRouterOwners[router]; }
7,267
190
// votereputation
mapping(uint256 => uint256 ) votes;
mapping(uint256 => uint256 ) votes;
45,152
8
// one mint for all
function mint(uint8 numberOfTokens) external payable { uint256 ts = totalSupply(); if(_mintedForFree[msg.sender] == 0 && ts < MAX_FREE_SUPPLY){ uint8 freeAmount = 1; require(isSaleActive, "Free mint is not active"); require(freeAmount + _mintedForFree[msg.sender] <= FREE_MINT_AMOUNT, "Exceeded max available to purchase"); require(ts + freeAmount <= MAX_FREE_SUPPLY, "Purchase would exceed max tokens for free mint"); require(FREE_TOKEN_PRICE * freeAmount <= msg.value, "This is free"); _mintedForFree[msg.sender] += freeAmount; for (uint256 i = 0; i < freeAmount; i++) { _safeMint(msg.sender, ts + i); } }else{ require(isSaleActive, "Public Sale must be active to mint tokens"); require(numberOfTokens <= 5,"Only 5 per Transaction allowed"); require(_mintedFromAddress[msg.sender] + numberOfTokens <= MAX_PUBLIC_MINT, "can not mint this many"); require(ts + numberOfTokens <= MAX_SUPPLY, "Purchase would exceed max tokens"); require(PUBLIC_PRICE_PER_TOKEN * numberOfTokens <= msg.value, "Ether value sent is not correct"); _mintedFromAddress[msg.sender] += numberOfTokens; for (uint256 i = 0; i < numberOfTokens; i++) { _safeMint(msg.sender, ts + i); } } }
function mint(uint8 numberOfTokens) external payable { uint256 ts = totalSupply(); if(_mintedForFree[msg.sender] == 0 && ts < MAX_FREE_SUPPLY){ uint8 freeAmount = 1; require(isSaleActive, "Free mint is not active"); require(freeAmount + _mintedForFree[msg.sender] <= FREE_MINT_AMOUNT, "Exceeded max available to purchase"); require(ts + freeAmount <= MAX_FREE_SUPPLY, "Purchase would exceed max tokens for free mint"); require(FREE_TOKEN_PRICE * freeAmount <= msg.value, "This is free"); _mintedForFree[msg.sender] += freeAmount; for (uint256 i = 0; i < freeAmount; i++) { _safeMint(msg.sender, ts + i); } }else{ require(isSaleActive, "Public Sale must be active to mint tokens"); require(numberOfTokens <= 5,"Only 5 per Transaction allowed"); require(_mintedFromAddress[msg.sender] + numberOfTokens <= MAX_PUBLIC_MINT, "can not mint this many"); require(ts + numberOfTokens <= MAX_SUPPLY, "Purchase would exceed max tokens"); require(PUBLIC_PRICE_PER_TOKEN * numberOfTokens <= msg.value, "Ether value sent is not correct"); _mintedFromAddress[msg.sender] += numberOfTokens; for (uint256 i = 0; i < numberOfTokens; i++) { _safeMint(msg.sender, ts + i); } } }
33,413
9
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) { return prod0 / denominator; }
if (prod1 == 0) { return prod0 / denominator; }
1,425
21
// mint tokens using the OG WhitelistamountPaid the number of tokens that are being paid foramountFree the number of free tokens being claimedboostPercent increase the odds of minting poachers to this percentstake stake the tokens if true/
function mintOGWhitelist(uint256 amountPaid, uint256 amountFree, uint256 boostPercent, bool stake) external payable whenNotPaused whenWhitelistMint { require(amountPaid * WHITELIST_MINT_PRICE == msg.value, "wrong payment amount"); uint16 offset; uint8 bought; uint8 claimed; uint8 lions; uint8 zebras; uint256 packedInfo = ogWhitelist.getInfoPacked(_msgSender()); offset = uint16(packedInfo >> 32); bought = uint8(packedInfo >> 24); claimed = uint8(packedInfo >> 16); lions = uint8(packedInfo >> 8); zebras = uint8(packedInfo); uint256 totalBought = amountPaid + bought; uint256 totalClaimed = amountFree + claimed; uint256 totalCredits = freeCredits(totalBought, lions, zebras); require(totalClaimed <= totalCredits, 'not enough free credits'); if (totalBought > 255) { totalBought = 255; } uint16 boughtAndClaimed = uint16((totalBought << 8) + totalClaimed); ogWhitelist.setBoughtAndClaimed(offset, boughtAndClaimed); uint256 amount = amountPaid + amountFree; _mintGen0(amount, boostPercent, stake); }
function mintOGWhitelist(uint256 amountPaid, uint256 amountFree, uint256 boostPercent, bool stake) external payable whenNotPaused whenWhitelistMint { require(amountPaid * WHITELIST_MINT_PRICE == msg.value, "wrong payment amount"); uint16 offset; uint8 bought; uint8 claimed; uint8 lions; uint8 zebras; uint256 packedInfo = ogWhitelist.getInfoPacked(_msgSender()); offset = uint16(packedInfo >> 32); bought = uint8(packedInfo >> 24); claimed = uint8(packedInfo >> 16); lions = uint8(packedInfo >> 8); zebras = uint8(packedInfo); uint256 totalBought = amountPaid + bought; uint256 totalClaimed = amountFree + claimed; uint256 totalCredits = freeCredits(totalBought, lions, zebras); require(totalClaimed <= totalCredits, 'not enough free credits'); if (totalBought > 255) { totalBought = 255; } uint16 boughtAndClaimed = uint16((totalBought << 8) + totalClaimed); ogWhitelist.setBoughtAndClaimed(offset, boughtAndClaimed); uint256 amount = amountPaid + amountFree; _mintGen0(amount, boostPercent, stake); }
38,192
2
// Pool validator withdrawal credentials.
bytes32 public override withdrawalCredentials;
bytes32 public override withdrawalCredentials;
30,614
8
// function disableStakingPool(/address payable _pool/) public isNotUpgraded optionalProxy_onlyOwner
// { // this; // }
// { // this; // }
40,434
59
// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver.onERC721Received}, which is called upon a safe transfer./ Additionally passes `data` in the callback./to The address to mint to./amount The amount of tokens to mint./data The calldata to pass in the {ERC721TokenReceiver.onERC721Received} callback.
function _safeMint( address to, uint256 amount, bytes memory data ) internal virtual { _mint(to, amount); require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, currentIndex - amount, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT"); }
function _safeMint( address to, uint256 amount, bytes memory data ) internal virtual { _mint(to, amount); require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, currentIndex - amount, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT"); }
9,025
10
// Min ratio of (FRAX + 3CRV) <-> FRAX3CRV-f-2 metapool conversions via add_liquidity / remove_liquidity; 1e6
uint256 public add_liq_slippage_metapool = 950000; uint256 public rem_liq_slippage_metapool = 950000;
uint256 public add_liq_slippage_metapool = 950000; uint256 public rem_liq_slippage_metapool = 950000;
21,872
11
// Vanilla transfer
ICapTables(capTables).transfer(index, tfr.src, tfr.dest, tfr.amount);
ICapTables(capTables).transfer(index, tfr.src, tfr.dest, tfr.amount);
30,829
310
// Indicator that this is a Comptroller contract (for inspection)
bool public constant isComptroller = true;
bool public constant isComptroller = true;
66,005
81
// this structure can be optimized
struct Dispute { uint timestamp; string reason; address[5] voters; mapping(address => address) votes; uint votesProject; uint votesInvestor; }
struct Dispute { uint timestamp; string reason; address[5] voters; mapping(address => address) votes; uint votesProject; uint votesInvestor; }
55,477
3
// Query all owned ERC1155 NFTs
TokenInfo[] memory ownedNFTs = new TokenInfo[](numOwnedNFTs); uint256 nftCount = 0; for (uint256 j = 0; j < _mintedTokenIds.length; j++) { uint256 tokenId = _mintedTokenIds[j]; if (balanceOf(user, tokenId) > 0) { ownedNFTs[nftCount] = TokenInfo( tokenId, balanceOf(user, tokenId), uri(tokenId) );
TokenInfo[] memory ownedNFTs = new TokenInfo[](numOwnedNFTs); uint256 nftCount = 0; for (uint256 j = 0; j < _mintedTokenIds.length; j++) { uint256 tokenId = _mintedTokenIds[j]; if (balanceOf(user, tokenId) > 0) { ownedNFTs[nftCount] = TokenInfo( tokenId, balanceOf(user, tokenId), uri(tokenId) );
24,394
80
// Get the EIP-712 hash of an ERC721 sell order./order The ERC721 sell order./ return orderHash The order hash.
function getERC721SellOrderHash(LibNFTOrder.NFTSellOrder memory order) public override view returns (bytes32) { return _getEIP712Hash(LibNFTOrder.getNFTSellOrderStructHash( order, LibCommonNftOrdersStorage.getStorage().hashNonces[order.maker])); }
function getERC721SellOrderHash(LibNFTOrder.NFTSellOrder memory order) public override view returns (bytes32) { return _getEIP712Hash(LibNFTOrder.getNFTSellOrderStructHash( order, LibCommonNftOrdersStorage.getStorage().hashNonces[order.maker])); }
43,169
13
// Get a reference to the redemption rate of the provided tokens.
uint256 _redemptionWeight = _redemptionWeightOf(_decodedTokenIds, _data);
uint256 _redemptionWeight = _redemptionWeightOf(_decodedTokenIds, _data);
11,846
219
// add eth to pot
round_[_rID].pot = _pot.add(_dust).add(round_[_rID].pot);
round_[_rID].pot = _pot.add(_dust).add(round_[_rID].pot);
34,885
6
// Ensure token has been minted by contract Reverts if token does not exist /
modifier tokenExists(uint256 tokenID) { require(tokenID > 0, "Mintango#tokenExists: INVALID_TOKEN_ID"); require( tokenID <= _currentTokenID, "Mintango#tokenExists: TOKEN_ID_DOES_NOT_EXIST" ); _; }
modifier tokenExists(uint256 tokenID) { require(tokenID > 0, "Mintango#tokenExists: INVALID_TOKEN_ID"); require( tokenID <= _currentTokenID, "Mintango#tokenExists: TOKEN_ID_DOES_NOT_EXIST" ); _; }
31,963
14
// if (includeCommission) { prizePool = prizePool.sub(prizePool.div(2)); }
return prizepool;
return prizepool;
5,954
85
// Transfer Property ownership between accounts. This has no cost, no cut and does not change flag status
function transferProperty(uint16 propertyID, address newOwner) public validPropertyID(propertyID) returns(bool) { require(pxlProperty.getPropertyOwner(propertyID) == msg.sender); _transferProperty(propertyID, newOwner, 0, 0, pxlProperty.getPropertyFlag(propertyID), msg.sender); return true; }
function transferProperty(uint16 propertyID, address newOwner) public validPropertyID(propertyID) returns(bool) { require(pxlProperty.getPropertyOwner(propertyID) == msg.sender); _transferProperty(propertyID, newOwner, 0, 0, pxlProperty.getPropertyFlag(propertyID), msg.sender); return true; }
21,399
212
// Liquidate as much as possible to `want`, up to `_amountNeeded`
uint256 amountFreed; (amountFreed, _loss) = liquidatePosition(_amountNeeded);
uint256 amountFreed; (amountFreed, _loss) = liquidatePosition(_amountNeeded);
53,239
18
// Constructs the ASETTokenV1 contract and initiates token allocation and other properties. /
constructor() { //MINT THE 100M TOKENS TO INITIATE THE PROCESS _balances[owner()] = _totalSupply; emit Mint(address(0), owner(), _totalSupply); //MARK LAST MINT DATE: IMPORTANT FOR MINTING PROTECTION lastMintTimestamp = block.timestamp; //MARK THE FIRST PRICE POINT: IMPORTANT FOR PRESALE PRICE INCREASE lastPriceIncrementTimestamp = block.timestamp; //ALLOCATE TOKENS ACCORDING TO ASSETLINK TOKENOMICS address[] memory allocationAddresses = new address[](5); uint256[] memory allocationAmounts = new uint256[](5); allocationAddresses[0] = developmentWallet; allocationAmounts[0] = developmentAllocation; allocationAddresses[1] = reservesWallet; allocationAmounts[1] = reservesAllocation; allocationAddresses[2] = liquidityWallet; allocationAmounts[2] = liquidityAllocation; allocationAddresses[3] = partnershipsWallet; allocationAmounts[3] = partnershipsAllocation; allocationAddresses[4] = communityWallet; allocationAmounts[4] = communityAllocation; // Call batch transfer function to handle allocations _batchTransfer(owner(), allocationAddresses, allocationAmounts); }
constructor() { //MINT THE 100M TOKENS TO INITIATE THE PROCESS _balances[owner()] = _totalSupply; emit Mint(address(0), owner(), _totalSupply); //MARK LAST MINT DATE: IMPORTANT FOR MINTING PROTECTION lastMintTimestamp = block.timestamp; //MARK THE FIRST PRICE POINT: IMPORTANT FOR PRESALE PRICE INCREASE lastPriceIncrementTimestamp = block.timestamp; //ALLOCATE TOKENS ACCORDING TO ASSETLINK TOKENOMICS address[] memory allocationAddresses = new address[](5); uint256[] memory allocationAmounts = new uint256[](5); allocationAddresses[0] = developmentWallet; allocationAmounts[0] = developmentAllocation; allocationAddresses[1] = reservesWallet; allocationAmounts[1] = reservesAllocation; allocationAddresses[2] = liquidityWallet; allocationAmounts[2] = liquidityAllocation; allocationAddresses[3] = partnershipsWallet; allocationAmounts[3] = partnershipsAllocation; allocationAddresses[4] = communityWallet; allocationAmounts[4] = communityAllocation; // Call batch transfer function to handle allocations _batchTransfer(owner(), allocationAddresses, allocationAmounts); }
28,736
68
// Sets that address is now maintainer
_isMaintainer[_address] = true;
_isMaintainer[_address] = true;
50,018
52
// NOTE: If these parameters are changed, expectedMsgDataLength and/or TRANSMIT_MSGDATA_CONSTANT_LENGTH_COMPONENT need to be changed accordingly
bytes calldata _report, bytes32[] calldata _rs, bytes32[] calldata _ss, bytes32 _rawVs // signatures ) external
bytes calldata _report, bytes32[] calldata _rs, bytes32[] calldata _ss, bytes32 _rawVs // signatures ) external
22,764
4
// configurable variables name it should be decided on constructor/
string public tokenName = "Universe Finance";
string public tokenName = "Universe Finance";
117
226
// updating reserve borrows stable
_reserve.totalBorrowsStable = _reserve.totalBorrowsStable.add(_amount);
_reserve.totalBorrowsStable = _reserve.totalBorrowsStable.add(_amount);
34,866
27
// Sets or upgrades the RariFundManager of the RariFundController. newContract The address of the new RariFundManager contract. /
function setFundManager(address newContract) external onlyOwner { // Approve maximum output tokens to RariFundManager for (uint256 i = 0; i < _supportedCurrencies.length; i++) { IERC20 token = IERC20(_erc20Contracts[_supportedCurrencies[i]]); if (_rariFundManagerContract != address(0)) token.safeApprove(_rariFundManagerContract, 0); if (newContract != address(0)) token.safeApprove(newContract, uint256(-1)); } _rariFundManagerContract = newContract; rariFundManager = RariFundManager(_rariFundManagerContract); emit FundManagerSet(newContract); }
function setFundManager(address newContract) external onlyOwner { // Approve maximum output tokens to RariFundManager for (uint256 i = 0; i < _supportedCurrencies.length; i++) { IERC20 token = IERC20(_erc20Contracts[_supportedCurrencies[i]]); if (_rariFundManagerContract != address(0)) token.safeApprove(_rariFundManagerContract, 0); if (newContract != address(0)) token.safeApprove(newContract, uint256(-1)); } _rariFundManagerContract = newContract; rariFundManager = RariFundManager(_rariFundManagerContract); emit FundManagerSet(newContract); }
13,221
12
// Register a differed payment. _wallet The payment wallet address. _ethAmount The payment amount in ETH. /
function registerDifferPayment(address _wallet, uint256 _ethAmount) external;
function registerDifferPayment(address _wallet, uint256 _ethAmount) external;
47,548
18
// Extensions of abstract contract Adapters which implementproposals submissions to Agora.Allow contract to manage proposals counters, check vote result andrisk mitigation /
abstract contract ProposerAdapter is Adapter, IProposerAdapter { using ProposalState for ProposalState.State; ProposalState.State private _state; modifier paused() { require(!_state.paused(), "Adapter: paused"); _; } /** * @notice called to finalize and archive a proposal * {_executeProposal} if accepted, this latter * function must be overrided in adapter implementation * with the logic of the adapter * * NOTE This function shouldn't be overrided (virtual), but maybe * it would be an option */ function finalizeProposal(bytes32 proposalId) external onlyMember { (bool accepted, IAgora agora) = _checkProposalResult(proposalId); if (accepted) { _executeProposal(proposalId); } _archiveProposal(); agora.finalizeProposal(proposalId, msg.sender, accepted); } /** * @notice delete the archive after one year, Agora * store and do check before calling this function */ function deleteArchive(bytes32) external virtual onlyExtension(Slot.AGORA) { // implement logic here _state.decrementArchive(); } /** * @notice allow an admin to pause and unpause the adapter * @dev inverse the current pause state */ function pauseToggleAdapter() external onlyAdmin { _state.pauseToggle(); } /** * @notice desactivate the adapter * @dev CAUTION this function is not reversible, * only triggerable when there is no ongoing proposal */ function desactive() external onlyAdmin { require(_state.currentOngoing() == 0, "Proposer: ongoing proposals"); _state.desactivate(); } /** * @notice getter for current numbers of ongoing proposal */ function ongoingProposals() external view returns (uint256) { return _state.currentOngoing(); } /** * @notice getter for current numbers of archived proposal */ function archivedProposals() external view returns (uint256) { return _state.currentArchive(); } function isPaused() external view returns (bool) { return _state.paused(); } function isDesactived() external view returns (bool) { return _state.desactived(); } /* ////////////////////////// INTERNAL FUNCTIONS ////////////////////////// */ /** * @notice decrement ongoing proposal and increment * archived proposal counter * * NOTE should be used when {Adapter::finalizeProposal} */ function _archiveProposal() internal paused { _state.decrementOngoing(); _state.incrementArchive(); } /** * @notice called after a proposal is submitted to Agora. * @dev will increase the proposal counter, check if the * adapter has not been paused and check also if the * adapter has not been desactived */ function _newProposal() internal paused { require(!_state.desactived(), "Proposer: adapter desactived"); _state.incrementOngoing(); } /** * @notice allow the proposal to check the vote result on * Agora, this function is only used (so far) when the adapter * needs to finalize a proposal * * @dev the function returns the {VoteResult} enum and the * {IAgora} interface to facilitate the result transmission to Agora * * NOTE This function could be transformed into a modifier which act * before and after the function {Adapter::finalizeProposal} as this * latter must call {Agora::finalizeProposal} then. */ function _checkProposalResult(bytes32 proposalId) internal view returns (bool accepted, IAgora agora) { agora = IAgora(_slotAddress(Slot.AGORA)); require( agora.getProposalStatus(proposalId) == IAgora.ProposalStatus.TO_FINALIZE, "Agora: proposal cannot be finalized" ); accepted = agora.getVoteResult(proposalId); } /** * @notice this function is used as a hook to execute the * adapter logic when a proposal has been accepted. * @dev triggered by {finalizeProposal} */ function _executeProposal(bytes32 proposalId) internal virtual {} function _readProposalId(bytes32 proposalId) internal pure returns (bytes28) { return bytes28(proposalId << 32); } }
abstract contract ProposerAdapter is Adapter, IProposerAdapter { using ProposalState for ProposalState.State; ProposalState.State private _state; modifier paused() { require(!_state.paused(), "Adapter: paused"); _; } /** * @notice called to finalize and archive a proposal * {_executeProposal} if accepted, this latter * function must be overrided in adapter implementation * with the logic of the adapter * * NOTE This function shouldn't be overrided (virtual), but maybe * it would be an option */ function finalizeProposal(bytes32 proposalId) external onlyMember { (bool accepted, IAgora agora) = _checkProposalResult(proposalId); if (accepted) { _executeProposal(proposalId); } _archiveProposal(); agora.finalizeProposal(proposalId, msg.sender, accepted); } /** * @notice delete the archive after one year, Agora * store and do check before calling this function */ function deleteArchive(bytes32) external virtual onlyExtension(Slot.AGORA) { // implement logic here _state.decrementArchive(); } /** * @notice allow an admin to pause and unpause the adapter * @dev inverse the current pause state */ function pauseToggleAdapter() external onlyAdmin { _state.pauseToggle(); } /** * @notice desactivate the adapter * @dev CAUTION this function is not reversible, * only triggerable when there is no ongoing proposal */ function desactive() external onlyAdmin { require(_state.currentOngoing() == 0, "Proposer: ongoing proposals"); _state.desactivate(); } /** * @notice getter for current numbers of ongoing proposal */ function ongoingProposals() external view returns (uint256) { return _state.currentOngoing(); } /** * @notice getter for current numbers of archived proposal */ function archivedProposals() external view returns (uint256) { return _state.currentArchive(); } function isPaused() external view returns (bool) { return _state.paused(); } function isDesactived() external view returns (bool) { return _state.desactived(); } /* ////////////////////////// INTERNAL FUNCTIONS ////////////////////////// */ /** * @notice decrement ongoing proposal and increment * archived proposal counter * * NOTE should be used when {Adapter::finalizeProposal} */ function _archiveProposal() internal paused { _state.decrementOngoing(); _state.incrementArchive(); } /** * @notice called after a proposal is submitted to Agora. * @dev will increase the proposal counter, check if the * adapter has not been paused and check also if the * adapter has not been desactived */ function _newProposal() internal paused { require(!_state.desactived(), "Proposer: adapter desactived"); _state.incrementOngoing(); } /** * @notice allow the proposal to check the vote result on * Agora, this function is only used (so far) when the adapter * needs to finalize a proposal * * @dev the function returns the {VoteResult} enum and the * {IAgora} interface to facilitate the result transmission to Agora * * NOTE This function could be transformed into a modifier which act * before and after the function {Adapter::finalizeProposal} as this * latter must call {Agora::finalizeProposal} then. */ function _checkProposalResult(bytes32 proposalId) internal view returns (bool accepted, IAgora agora) { agora = IAgora(_slotAddress(Slot.AGORA)); require( agora.getProposalStatus(proposalId) == IAgora.ProposalStatus.TO_FINALIZE, "Agora: proposal cannot be finalized" ); accepted = agora.getVoteResult(proposalId); } /** * @notice this function is used as a hook to execute the * adapter logic when a proposal has been accepted. * @dev triggered by {finalizeProposal} */ function _executeProposal(bytes32 proposalId) internal virtual {} function _readProposalId(bytes32 proposalId) internal pure returns (bytes28) { return bytes28(proposalId << 32); } }
30,093
24
// open lost check
if ((order.limitPrice - marketPrice) * order.qty * 1e4 >= marginUsd * lm.initialLostP) { return (false, 0, 0, Refund.OPEN_LOST); }
if ((order.limitPrice - marketPrice) * order.qty * 1e4 >= marginUsd * lm.initialLostP) { return (false, 0, 0, Refund.OPEN_LOST); }
12,001
27
// Verify the deprecation of a state update exit ABI encoded PlasmaExit data inputUtxo ABI encoded Input UTXO data challengeData RLP encoded data of the challenge reference tx that encodes the following fields headerNumber Header block number of which the reference tx was a part of blockProof Proof that the block header (in the child chain) is a leaf in the submitted merkle root blockNumber Block number of which the reference tx is a part of blockTime Reference tx block time blocktxRoot Transactions root of block blockReceiptsRoot Receipts root of block receipt Receipt of the reference transaction receiptProof Merkle proof of
function verifyDeprecation(bytes calldata exit, bytes calldata inputUtxo, bytes calldata challengeData) external returns (bool)
function verifyDeprecation(bytes calldata exit, bytes calldata inputUtxo, bytes calldata challengeData) external returns (bool)
14,779
234
// Copyright 2018, Konstantin Viktorov (EscrowBlock Foundation)Copyright 2017, Jorge Izquierdo (Aragon Foundation)Copyright 2017, Jordi Baylina (Giveth) This is the new token sale smart contract for conduction IITO and Airdrop together,also it will allow having a stable price for some period after exchange listing. /
contract ESCBTokenSale is TokenController { uint256 public initialTime; // Time in which the sale starts. Inclusive. sale will be opened at initial time. uint256 public controlTime; // The Unix time in which the sale needs to check on the refunding start. uint256 public price; // Number of wei-ESCBCoin tokens for 1 ether address public ESCBDevMultisig; // The address to hold the funds donated uint256 public affiliateBonusPercent = 2; // Purpose in percentage of payment via referral uint256 public totalCollected = 0; // In wei bool public saleStopped = false; // Has ESCB Dev stopped the sale? bool public saleFinalized = false; // Has ESCB Dev finalized the sale? mapping (address => bool) public activated; // Address confirmates that wants to activate the sale ESCBCoin public token; // The token ESCBCoinPlaceholder public networkPlaceholder; // The network placeholder SaleWallet public saleWallet; // Wallet that receives all sale funds uint256 constant public dust = 1 finney; // Minimum investment uint256 public minGoal; // amount of minimum fund in wei uint256 public goal; // Goal for IITO in wei uint256 public currentStage = 1; // Current stage uint256 public allocatedStage = 1; // Current stage when was allocated tokens for ESCB uint256 public usedTotalSupply = 0; // This uses for calculation ESCB allocation part event ActivatedSale(); event FinalizedSale(); event NewBuyer(address indexed holder, uint256 ESCBCoinAmount, uint256 etherAmount); event NewExternalFoundation(address indexed holder, uint256 ESCBCoinAmount, uint256 etherAmount, bytes32 externalId); event AllocationForESCBFund(address indexed holder, uint256 ESCBCoinAmount); event NewStage(uint64 numberStage); // @dev There are several checks to make sure the parameters are acceptable // @param _initialTime The Unix time in which the sale starts // @param _controlTime The Unix time in which the sale needs to check on the refunding start // @param _ESCBDevMultisig The address that will store the donated funds and manager for the sale // @param _price The price. Price in wei-ESCBCoin per wei function ESCBTokenSale (uint _initialTime, uint _controlTime, address _ESCBDevMultisig, uint256 _price) non_zero_address(_ESCBDevMultisig) { assert (_initialTime >= getNow()); assert (_initialTime < _controlTime); // Save constructor arguments as global variables initialTime = _initialTime; controlTime = _controlTime; ESCBDevMultisig = _ESCBDevMultisig; price = _price; } modifier only(address x) { require(msg.sender == x); _; } modifier only_before_sale { require(getNow() < initialTime); _; } modifier only_during_sale_period { require(getNow() >= initialTime); // if minimum goal is reached, then infinite time to reach the main goal require(getNow() < controlTime || minGoalReached()); _; } modifier only_after_sale { require(getNow() >= controlTime || goalReached()); _; } modifier only_sale_stopped { require(saleStopped); _; } modifier only_sale_not_stopped { require(!saleStopped); _; } modifier only_before_sale_activation { require(!isActivated()); _; } modifier only_sale_activated { require(isActivated()); _; } modifier only_finalized_sale { require(getNow() >= controlTime || goalReached()); require(saleFinalized); _; } modifier non_zero_address(address x) { require(x != 0); _; } modifier minimum_value(uint256 x) { require(msg.value >= x); _; } // @notice Deploy ESCBCoin is called only once to setup all the needed contracts. // @param _token: Address of an instance of the ESCBCoin token // @param _networkPlaceholder: Address of an instance of ESCBCoinPlaceholder // @param _saleWallet: Address of the wallet receiving the funds of the sale // @param _minGoal: Minimum fund for success // @param _goal: The end fund amount function setESCBCoin(address _token, address _networkPlaceholder, address _saleWallet, uint256 _minGoal, uint256 _goal) payable non_zero_address(_token) only(ESCBDevMultisig) public { // 3 times by non_zero_address is not working for current compiler version require(_networkPlaceholder != 0); require(_saleWallet != 0); // Assert that the function hasn&#39;t been called before, as activate will happen at the end assert(!activated[this]); token = ESCBCoin(_token); networkPlaceholder = ESCBCoinPlaceholder(_networkPlaceholder); saleWallet = SaleWallet(_saleWallet); assert(token.controller() == address(this)); // sale is controller assert(token.totalSupply() == 0); // token is empty assert(networkPlaceholder.tokenSale() == address(this)); // placeholder has reference to Sale assert(networkPlaceholder.token() == address(token)); // placeholder has reference to ESCBCoin assert(saleWallet.multisig() == ESCBDevMultisig); // receiving wallet must match assert(saleWallet.tokenSale() == address(this)); // watched token sale must be self assert(_minGoal > 0); // minimum goal is not empty assert(_goal > 0); // the main goal is not empty assert(_minGoal < _goal); // minimum goal is less than the main goal minGoal = _minGoal; goal = _goal; // Contract activates sale as all requirements are ready doActivateSale(this); } function activateSale() public { doActivateSale(msg.sender); ActivatedSale(); } function doActivateSale(address _entity) non_zero_address(token) // cannot activate before setting token only_before_sale private { activated[_entity] = true; } // @notice Whether the needed accounts have activated the sale. // @return Is sale activated function isActivated() constant public returns (bool) { return activated[this] && activated[ESCBDevMultisig]; } // @notice Get the price for tokens for the current stage // @param _amount the amount for which the price is requested // @return Number of wei-ESCBToken function getPrice(uint256 _amount) only_during_sale_period only_sale_not_stopped only_sale_activated constant public returns (uint256) { return priceForStage(SafeMath.mul(_amount, price)); } // @notice Get the bonus tokens for a stage // @param _amount the amount of tokens // @return Number of wei-ESCBCoin with bonus for 1 wei function priceForStage(uint256 _amount) internal returns (uint256) { if (totalCollected >= 0 && totalCollected <= 80 ether) { // 1 ETH = 500 USD, then 40 000 USD 1 stage return SafeMath.add(_amount, SafeMath.div(SafeMath.mul(_amount, 20), 100)); } if (totalCollected > 80 ether && totalCollected <= 200 ether) { // 1 ETH = 500 USD, then 100 000 USD 2 stage return SafeMath.add(_amount, SafeMath.div(SafeMath.mul(_amount, 18), 100)); } if (totalCollected > 200 ether && totalCollected <= 400 ether) { // 1 ETH = 500 USD, then 200 000 USD 3 stage return SafeMath.add(_amount, SafeMath.div(SafeMath.mul(_amount, 16), 100)); } if (totalCollected > 400 ether && totalCollected <= 1000 ether) { // 1 ETH = 500 USD, then 500 000 USD 4 stage return SafeMath.add(_amount, SafeMath.div(SafeMath.mul(_amount, 14), 100)); } if (totalCollected > 1000 ether && totalCollected <= 2000 ether) { // 1 ETH = 500 USD, then 1 000 000 USD 5 stage return SafeMath.add(_amount, SafeMath.div(SafeMath.mul(_amount, 12), 100)); } if (totalCollected > 2000 ether && totalCollected <= 4000 ether) { // 1 ETH = 500 USD, then 2 000 000 USD 6 stage return SafeMath.add(_amount, SafeMath.div(SafeMath.mul(_amount, 10), 100)); } if (totalCollected > 4000 ether && totalCollected <= 8000 ether) { // 1 ETH = 500 USD, then 4 000 000 USD 7 stage return SafeMath.add(_amount, SafeMath.div(SafeMath.mul(_amount, 8), 100)); } if (totalCollected > 8000 ether && totalCollected <= 12000 ether) { // 1 ETH = 500 USD, then 6 000 000 USD 8 stage return SafeMath.add(_amount, SafeMath.div(SafeMath.mul(_amount, 6), 100)); } if (totalCollected > 12000 ether && totalCollected <= 16000 ether) { // 1 ETH = 500 USD, then 8 000 000 USD 9 stage return SafeMath.add(_amount, SafeMath.div(SafeMath.mul(_amount, 4), 100)); } if (totalCollected > 16000 ether && totalCollected <= 20000 ether) { // 1 ETH = 500 USD, then 10 000 000 USD 10 stage return SafeMath.add(_amount, SafeMath.div(SafeMath.mul(_amount, 2), 100)); } if (totalCollected > 20000 ether) { // without bonus return _amount; } } // ESCBDevMultisig can use this function for allocation tokens // for ESCB Foundation by each stage, start from 2nd // Amount of stages can not be more than MAX_GRANTS_PER_ADDRESS function allocationForESCBbyStage() only(ESCBDevMultisig) public { if (totalCollected >= 0 && totalCollected <= 80 ether) { // 1 ETH = 500 USD, then 40 000 USD 1 stage currentStage = 1; } if (totalCollected > 80 ether && totalCollected <= 200 ether) { // 1 ETH = 500 USD, then 100 000 USD 2 stage currentStage = 2; } if (totalCollected > 200 ether && totalCollected <= 400 ether) { // 1 ETH = 500 USD, then 200 000 USD 3 stage currentStage = 3; } if (totalCollected > 400 ether && totalCollected <= 1000 ether) { // 1 ETH = 500 USD, then 500 000 USD 4 stage currentStage = 4; } if (totalCollected > 1000 ether && totalCollected <= 2000 ether) { // 1 ETH = 500 USD, then 1 000 000 USD 5 stage currentStage = 5; } if (totalCollected > 2000 ether && totalCollected <= 4000 ether) { // 1 ETH = 500 USD, then 2 000 000 USD 6 stage currentStage = 6; } if (totalCollected > 4000 ether && totalCollected <= 8000 ether) { // 1 ETH = 500 USD, then 4 000 000 USD 7 stage currentStage = 7; } if (totalCollected > 8000 ether && totalCollected <= 12000 ether) { // 1 ETH = 500 USD, then 6 000 000 USD 8 stage currentStage = 8; } if (totalCollected > 12000 ether && totalCollected <= 16000 ether) { // 1 ETH = 500 USD, then 8 000 000 USD 9 stage currentStage = 9; } if (totalCollected > 16000 ether && totalCollected <= 20000 ether) { // 1 ETH = 500 USD, then 10 000 000 USD 10 stage currentStage = 10; } if(currentStage > allocatedStage) { // ESCB Foundation owns 30% of the total number of emitted tokens. // totalSupply here 66%, then we 30%/66% to get amount 30% of tokens uint256 ESCBTokens = SafeMath.div(SafeMath.mul(SafeMath.sub(uint256(token.totalSupply()), usedTotalSupply), 15), 33); uint256 prevTotalSupply = uint256(token.totalSupply()); if(token.generateTokens(address(this), ESCBTokens)) { allocatedStage = currentStage; usedTotalSupply = prevTotalSupply; uint64 cliffDate = uint64(SafeMath.add(uint256(now), 365 days)); uint64 vestingDate = uint64(SafeMath.add(uint256(now), 547 days)); token.grantVestedTokens(ESCBDevMultisig, ESCBTokens, uint64(now), cliffDate, vestingDate, true, false); AllocationForESCBFund(ESCBDevMultisig, ESCBTokens); } else { revert(); } } } // @notice Notifies the controller about a transfer, for this sale all // transfers are allowed by default and no extra notifications are needed // @param _from The origin of the transfer // @param _to The destination of the transfer // @param _amount The amount of the transfer // @return False if the controller does not authorize the transfer function onTransfer(address _from, address _to, uint _amount) public returns (bool) { return true; } // @notice Notifies the controller about an approval, for this sale all // approvals are allowed by default and no extra notifications are needed // @param _owner The address that calls `approve()` // @param _spender The spender in the `approve()` call // @param _amount The amount in the `approve()` call // @return False if the controller does not authorize the approval function onApprove(address _owner, address _spender, uint _amount) public returns (bool) { return true; } // @dev The fallback function is called when ether is sent to the contract, it // simply calls `doPayment()` with the address that sent the ether as the // `_owner`. Payable is a require solidity modifier for functions to receive // ether, without this modifier functions will throw if ether is sent to them function () public payable { doPayment(msg.sender); } // @dev This function allow to get bonus tokens for a buyer and for referral function paymentAffiliate(address _referral) non_zero_address(_referral) payable public { uint256 boughtTokens = doPayment(msg.sender); uint256 affiliateBonus = SafeMath.div( SafeMath.mul(boughtTokens, affiliateBonusPercent), 100 ); // Calculate how many bonus tokens need to add assert(token.generateTokens(_referral, affiliateBonus)); assert(token.generateTokens(msg.sender, affiliateBonus)); } //////////// // Controller interface //////////// // @notice `proxyPayment()` allows the caller to send ether to the Token directly and // have the tokens created in an address of their choosing // @param _owner The address that will hold the newly created tokens function proxyPayment(address _owner) payable public returns (bool) { doPayment(_owner); return true; } // @dev `doPayment()` is an internal function that sends the ether that this // contract receives to the ESCBDevMultisig and creates tokens in the address of the sender // @param _owner The address that will hold the newly created tokens function doPayment(address _owner) only_during_sale_period only_sale_not_stopped only_sale_activated non_zero_address(_owner) minimum_value(dust) internal returns (uint256) { assert(totalCollected + msg.value <= goal); // If goal is reached, throw uint256 boughtTokens = priceForStage(SafeMath.mul(msg.value, price)); // Calculate how many tokens bought saleWallet.transfer(msg.value); // Send funds to multisig saleWallet.deposit(_owner, msg.value); // Send info about deposit to multisig assert(token.generateTokens(_owner, boughtTokens)); // Allocate tokens. totalCollected = SafeMath.add(totalCollected, msg.value); // Save total collected amount NewBuyer(_owner, boughtTokens, msg.value); return boughtTokens; } // @notice Function for issuing new tokens for address which made purchasing not in // ETH currency, for example via cards or wire transfer. // @dev Only ESCB Dev can do it with the publishing of transaction id in an external system. // Any audits will be able to confirm eligibility of issuing in such case. // @param _owner The address that will hold the newly created tokens // @param _amount Amount of purchasing in ETH function issueWithExternalFoundation(address _owner, uint256 _amount, bytes32 _extId) only_during_sale_period only_sale_not_stopped only_sale_activated non_zero_address(_owner) only(ESCBDevMultisig) public returns (uint256) { assert(totalCollected + _amount <= goal); // If goal is reached, throw uint256 boughtTokens = priceForStage(SafeMath.mul(_amount, price)); // Calculate how many tokens bought assert(token.generateTokens(_owner, boughtTokens)); // Allocate tokens. totalCollected = SafeMath.add(totalCollected, _amount); // Save total collected amount // Events NewBuyer(_owner, boughtTokens, _amount); NewExternalFoundation(_owner, boughtTokens, _amount, _extId); return boughtTokens; } // @notice Function to stop sale for an emergency. // @dev Only ESCB Dev can do it after it has been activated. function emergencyStopSale() only_sale_activated only_sale_not_stopped only(ESCBDevMultisig) public { saleStopped = true; } // @notice Function to restart stopped sale. // @dev Only ESCB Dev can do it after it has been disabled and sale is ongoing. function restartSale() only_during_sale_period only_sale_stopped only(ESCBDevMultisig) public { saleStopped = false; } // @notice Finalizes sale when main goal is reached or if for control time the minimum goal was not reached. // @dev Transfers the token controller power to the ESCBCoinPlaceholder. function finalizeSale() only_after_sale only(ESCBDevMultisig) public { token.changeController(networkPlaceholder); // Sale loses token controller power in favor of network placeholder saleFinalized = true; // Set finalized flag as true, that will allow enabling network deployment saleStopped = true; FinalizedSale(); } // @notice Deploy ESCB Network contract. // @param _networkAddress: The address the network was deployed at. function deployNetwork(address _networkAddress) only_finalized_sale non_zero_address(_networkAddress) only(ESCBDevMultisig) public { networkPlaceholder.changeController(_networkAddress); } // @notice Set up new ESCB Dev. // @param _newMultisig: The address new ESCB Dev. function setESCBDevMultisig(address _newMultisig) non_zero_address(_newMultisig) only(ESCBDevMultisig) public { ESCBDevMultisig = _newMultisig; } // @notice Get current unix time stamp function getNow() constant internal returns (uint) { return now; } // @notice If crowdsale is unsuccessful, investors can claim refunds here function claimRefund() only_finalized_sale public { require(!minGoalReached()); saleWallet.refund(msg.sender); } // @notice Check minimum goal for 1st stage function minGoalReached() public view returns (bool) { return totalCollected >= minGoal; } // @notice Check the main goal for 10th stage function goalReached() public view returns (bool) { return totalCollected >= goal; } }
contract ESCBTokenSale is TokenController { uint256 public initialTime; // Time in which the sale starts. Inclusive. sale will be opened at initial time. uint256 public controlTime; // The Unix time in which the sale needs to check on the refunding start. uint256 public price; // Number of wei-ESCBCoin tokens for 1 ether address public ESCBDevMultisig; // The address to hold the funds donated uint256 public affiliateBonusPercent = 2; // Purpose in percentage of payment via referral uint256 public totalCollected = 0; // In wei bool public saleStopped = false; // Has ESCB Dev stopped the sale? bool public saleFinalized = false; // Has ESCB Dev finalized the sale? mapping (address => bool) public activated; // Address confirmates that wants to activate the sale ESCBCoin public token; // The token ESCBCoinPlaceholder public networkPlaceholder; // The network placeholder SaleWallet public saleWallet; // Wallet that receives all sale funds uint256 constant public dust = 1 finney; // Minimum investment uint256 public minGoal; // amount of minimum fund in wei uint256 public goal; // Goal for IITO in wei uint256 public currentStage = 1; // Current stage uint256 public allocatedStage = 1; // Current stage when was allocated tokens for ESCB uint256 public usedTotalSupply = 0; // This uses for calculation ESCB allocation part event ActivatedSale(); event FinalizedSale(); event NewBuyer(address indexed holder, uint256 ESCBCoinAmount, uint256 etherAmount); event NewExternalFoundation(address indexed holder, uint256 ESCBCoinAmount, uint256 etherAmount, bytes32 externalId); event AllocationForESCBFund(address indexed holder, uint256 ESCBCoinAmount); event NewStage(uint64 numberStage); // @dev There are several checks to make sure the parameters are acceptable // @param _initialTime The Unix time in which the sale starts // @param _controlTime The Unix time in which the sale needs to check on the refunding start // @param _ESCBDevMultisig The address that will store the donated funds and manager for the sale // @param _price The price. Price in wei-ESCBCoin per wei function ESCBTokenSale (uint _initialTime, uint _controlTime, address _ESCBDevMultisig, uint256 _price) non_zero_address(_ESCBDevMultisig) { assert (_initialTime >= getNow()); assert (_initialTime < _controlTime); // Save constructor arguments as global variables initialTime = _initialTime; controlTime = _controlTime; ESCBDevMultisig = _ESCBDevMultisig; price = _price; } modifier only(address x) { require(msg.sender == x); _; } modifier only_before_sale { require(getNow() < initialTime); _; } modifier only_during_sale_period { require(getNow() >= initialTime); // if minimum goal is reached, then infinite time to reach the main goal require(getNow() < controlTime || minGoalReached()); _; } modifier only_after_sale { require(getNow() >= controlTime || goalReached()); _; } modifier only_sale_stopped { require(saleStopped); _; } modifier only_sale_not_stopped { require(!saleStopped); _; } modifier only_before_sale_activation { require(!isActivated()); _; } modifier only_sale_activated { require(isActivated()); _; } modifier only_finalized_sale { require(getNow() >= controlTime || goalReached()); require(saleFinalized); _; } modifier non_zero_address(address x) { require(x != 0); _; } modifier minimum_value(uint256 x) { require(msg.value >= x); _; } // @notice Deploy ESCBCoin is called only once to setup all the needed contracts. // @param _token: Address of an instance of the ESCBCoin token // @param _networkPlaceholder: Address of an instance of ESCBCoinPlaceholder // @param _saleWallet: Address of the wallet receiving the funds of the sale // @param _minGoal: Minimum fund for success // @param _goal: The end fund amount function setESCBCoin(address _token, address _networkPlaceholder, address _saleWallet, uint256 _minGoal, uint256 _goal) payable non_zero_address(_token) only(ESCBDevMultisig) public { // 3 times by non_zero_address is not working for current compiler version require(_networkPlaceholder != 0); require(_saleWallet != 0); // Assert that the function hasn&#39;t been called before, as activate will happen at the end assert(!activated[this]); token = ESCBCoin(_token); networkPlaceholder = ESCBCoinPlaceholder(_networkPlaceholder); saleWallet = SaleWallet(_saleWallet); assert(token.controller() == address(this)); // sale is controller assert(token.totalSupply() == 0); // token is empty assert(networkPlaceholder.tokenSale() == address(this)); // placeholder has reference to Sale assert(networkPlaceholder.token() == address(token)); // placeholder has reference to ESCBCoin assert(saleWallet.multisig() == ESCBDevMultisig); // receiving wallet must match assert(saleWallet.tokenSale() == address(this)); // watched token sale must be self assert(_minGoal > 0); // minimum goal is not empty assert(_goal > 0); // the main goal is not empty assert(_minGoal < _goal); // minimum goal is less than the main goal minGoal = _minGoal; goal = _goal; // Contract activates sale as all requirements are ready doActivateSale(this); } function activateSale() public { doActivateSale(msg.sender); ActivatedSale(); } function doActivateSale(address _entity) non_zero_address(token) // cannot activate before setting token only_before_sale private { activated[_entity] = true; } // @notice Whether the needed accounts have activated the sale. // @return Is sale activated function isActivated() constant public returns (bool) { return activated[this] && activated[ESCBDevMultisig]; } // @notice Get the price for tokens for the current stage // @param _amount the amount for which the price is requested // @return Number of wei-ESCBToken function getPrice(uint256 _amount) only_during_sale_period only_sale_not_stopped only_sale_activated constant public returns (uint256) { return priceForStage(SafeMath.mul(_amount, price)); } // @notice Get the bonus tokens for a stage // @param _amount the amount of tokens // @return Number of wei-ESCBCoin with bonus for 1 wei function priceForStage(uint256 _amount) internal returns (uint256) { if (totalCollected >= 0 && totalCollected <= 80 ether) { // 1 ETH = 500 USD, then 40 000 USD 1 stage return SafeMath.add(_amount, SafeMath.div(SafeMath.mul(_amount, 20), 100)); } if (totalCollected > 80 ether && totalCollected <= 200 ether) { // 1 ETH = 500 USD, then 100 000 USD 2 stage return SafeMath.add(_amount, SafeMath.div(SafeMath.mul(_amount, 18), 100)); } if (totalCollected > 200 ether && totalCollected <= 400 ether) { // 1 ETH = 500 USD, then 200 000 USD 3 stage return SafeMath.add(_amount, SafeMath.div(SafeMath.mul(_amount, 16), 100)); } if (totalCollected > 400 ether && totalCollected <= 1000 ether) { // 1 ETH = 500 USD, then 500 000 USD 4 stage return SafeMath.add(_amount, SafeMath.div(SafeMath.mul(_amount, 14), 100)); } if (totalCollected > 1000 ether && totalCollected <= 2000 ether) { // 1 ETH = 500 USD, then 1 000 000 USD 5 stage return SafeMath.add(_amount, SafeMath.div(SafeMath.mul(_amount, 12), 100)); } if (totalCollected > 2000 ether && totalCollected <= 4000 ether) { // 1 ETH = 500 USD, then 2 000 000 USD 6 stage return SafeMath.add(_amount, SafeMath.div(SafeMath.mul(_amount, 10), 100)); } if (totalCollected > 4000 ether && totalCollected <= 8000 ether) { // 1 ETH = 500 USD, then 4 000 000 USD 7 stage return SafeMath.add(_amount, SafeMath.div(SafeMath.mul(_amount, 8), 100)); } if (totalCollected > 8000 ether && totalCollected <= 12000 ether) { // 1 ETH = 500 USD, then 6 000 000 USD 8 stage return SafeMath.add(_amount, SafeMath.div(SafeMath.mul(_amount, 6), 100)); } if (totalCollected > 12000 ether && totalCollected <= 16000 ether) { // 1 ETH = 500 USD, then 8 000 000 USD 9 stage return SafeMath.add(_amount, SafeMath.div(SafeMath.mul(_amount, 4), 100)); } if (totalCollected > 16000 ether && totalCollected <= 20000 ether) { // 1 ETH = 500 USD, then 10 000 000 USD 10 stage return SafeMath.add(_amount, SafeMath.div(SafeMath.mul(_amount, 2), 100)); } if (totalCollected > 20000 ether) { // without bonus return _amount; } } // ESCBDevMultisig can use this function for allocation tokens // for ESCB Foundation by each stage, start from 2nd // Amount of stages can not be more than MAX_GRANTS_PER_ADDRESS function allocationForESCBbyStage() only(ESCBDevMultisig) public { if (totalCollected >= 0 && totalCollected <= 80 ether) { // 1 ETH = 500 USD, then 40 000 USD 1 stage currentStage = 1; } if (totalCollected > 80 ether && totalCollected <= 200 ether) { // 1 ETH = 500 USD, then 100 000 USD 2 stage currentStage = 2; } if (totalCollected > 200 ether && totalCollected <= 400 ether) { // 1 ETH = 500 USD, then 200 000 USD 3 stage currentStage = 3; } if (totalCollected > 400 ether && totalCollected <= 1000 ether) { // 1 ETH = 500 USD, then 500 000 USD 4 stage currentStage = 4; } if (totalCollected > 1000 ether && totalCollected <= 2000 ether) { // 1 ETH = 500 USD, then 1 000 000 USD 5 stage currentStage = 5; } if (totalCollected > 2000 ether && totalCollected <= 4000 ether) { // 1 ETH = 500 USD, then 2 000 000 USD 6 stage currentStage = 6; } if (totalCollected > 4000 ether && totalCollected <= 8000 ether) { // 1 ETH = 500 USD, then 4 000 000 USD 7 stage currentStage = 7; } if (totalCollected > 8000 ether && totalCollected <= 12000 ether) { // 1 ETH = 500 USD, then 6 000 000 USD 8 stage currentStage = 8; } if (totalCollected > 12000 ether && totalCollected <= 16000 ether) { // 1 ETH = 500 USD, then 8 000 000 USD 9 stage currentStage = 9; } if (totalCollected > 16000 ether && totalCollected <= 20000 ether) { // 1 ETH = 500 USD, then 10 000 000 USD 10 stage currentStage = 10; } if(currentStage > allocatedStage) { // ESCB Foundation owns 30% of the total number of emitted tokens. // totalSupply here 66%, then we 30%/66% to get amount 30% of tokens uint256 ESCBTokens = SafeMath.div(SafeMath.mul(SafeMath.sub(uint256(token.totalSupply()), usedTotalSupply), 15), 33); uint256 prevTotalSupply = uint256(token.totalSupply()); if(token.generateTokens(address(this), ESCBTokens)) { allocatedStage = currentStage; usedTotalSupply = prevTotalSupply; uint64 cliffDate = uint64(SafeMath.add(uint256(now), 365 days)); uint64 vestingDate = uint64(SafeMath.add(uint256(now), 547 days)); token.grantVestedTokens(ESCBDevMultisig, ESCBTokens, uint64(now), cliffDate, vestingDate, true, false); AllocationForESCBFund(ESCBDevMultisig, ESCBTokens); } else { revert(); } } } // @notice Notifies the controller about a transfer, for this sale all // transfers are allowed by default and no extra notifications are needed // @param _from The origin of the transfer // @param _to The destination of the transfer // @param _amount The amount of the transfer // @return False if the controller does not authorize the transfer function onTransfer(address _from, address _to, uint _amount) public returns (bool) { return true; } // @notice Notifies the controller about an approval, for this sale all // approvals are allowed by default and no extra notifications are needed // @param _owner The address that calls `approve()` // @param _spender The spender in the `approve()` call // @param _amount The amount in the `approve()` call // @return False if the controller does not authorize the approval function onApprove(address _owner, address _spender, uint _amount) public returns (bool) { return true; } // @dev The fallback function is called when ether is sent to the contract, it // simply calls `doPayment()` with the address that sent the ether as the // `_owner`. Payable is a require solidity modifier for functions to receive // ether, without this modifier functions will throw if ether is sent to them function () public payable { doPayment(msg.sender); } // @dev This function allow to get bonus tokens for a buyer and for referral function paymentAffiliate(address _referral) non_zero_address(_referral) payable public { uint256 boughtTokens = doPayment(msg.sender); uint256 affiliateBonus = SafeMath.div( SafeMath.mul(boughtTokens, affiliateBonusPercent), 100 ); // Calculate how many bonus tokens need to add assert(token.generateTokens(_referral, affiliateBonus)); assert(token.generateTokens(msg.sender, affiliateBonus)); } //////////// // Controller interface //////////// // @notice `proxyPayment()` allows the caller to send ether to the Token directly and // have the tokens created in an address of their choosing // @param _owner The address that will hold the newly created tokens function proxyPayment(address _owner) payable public returns (bool) { doPayment(_owner); return true; } // @dev `doPayment()` is an internal function that sends the ether that this // contract receives to the ESCBDevMultisig and creates tokens in the address of the sender // @param _owner The address that will hold the newly created tokens function doPayment(address _owner) only_during_sale_period only_sale_not_stopped only_sale_activated non_zero_address(_owner) minimum_value(dust) internal returns (uint256) { assert(totalCollected + msg.value <= goal); // If goal is reached, throw uint256 boughtTokens = priceForStage(SafeMath.mul(msg.value, price)); // Calculate how many tokens bought saleWallet.transfer(msg.value); // Send funds to multisig saleWallet.deposit(_owner, msg.value); // Send info about deposit to multisig assert(token.generateTokens(_owner, boughtTokens)); // Allocate tokens. totalCollected = SafeMath.add(totalCollected, msg.value); // Save total collected amount NewBuyer(_owner, boughtTokens, msg.value); return boughtTokens; } // @notice Function for issuing new tokens for address which made purchasing not in // ETH currency, for example via cards or wire transfer. // @dev Only ESCB Dev can do it with the publishing of transaction id in an external system. // Any audits will be able to confirm eligibility of issuing in such case. // @param _owner The address that will hold the newly created tokens // @param _amount Amount of purchasing in ETH function issueWithExternalFoundation(address _owner, uint256 _amount, bytes32 _extId) only_during_sale_period only_sale_not_stopped only_sale_activated non_zero_address(_owner) only(ESCBDevMultisig) public returns (uint256) { assert(totalCollected + _amount <= goal); // If goal is reached, throw uint256 boughtTokens = priceForStage(SafeMath.mul(_amount, price)); // Calculate how many tokens bought assert(token.generateTokens(_owner, boughtTokens)); // Allocate tokens. totalCollected = SafeMath.add(totalCollected, _amount); // Save total collected amount // Events NewBuyer(_owner, boughtTokens, _amount); NewExternalFoundation(_owner, boughtTokens, _amount, _extId); return boughtTokens; } // @notice Function to stop sale for an emergency. // @dev Only ESCB Dev can do it after it has been activated. function emergencyStopSale() only_sale_activated only_sale_not_stopped only(ESCBDevMultisig) public { saleStopped = true; } // @notice Function to restart stopped sale. // @dev Only ESCB Dev can do it after it has been disabled and sale is ongoing. function restartSale() only_during_sale_period only_sale_stopped only(ESCBDevMultisig) public { saleStopped = false; } // @notice Finalizes sale when main goal is reached or if for control time the minimum goal was not reached. // @dev Transfers the token controller power to the ESCBCoinPlaceholder. function finalizeSale() only_after_sale only(ESCBDevMultisig) public { token.changeController(networkPlaceholder); // Sale loses token controller power in favor of network placeholder saleFinalized = true; // Set finalized flag as true, that will allow enabling network deployment saleStopped = true; FinalizedSale(); } // @notice Deploy ESCB Network contract. // @param _networkAddress: The address the network was deployed at. function deployNetwork(address _networkAddress) only_finalized_sale non_zero_address(_networkAddress) only(ESCBDevMultisig) public { networkPlaceholder.changeController(_networkAddress); } // @notice Set up new ESCB Dev. // @param _newMultisig: The address new ESCB Dev. function setESCBDevMultisig(address _newMultisig) non_zero_address(_newMultisig) only(ESCBDevMultisig) public { ESCBDevMultisig = _newMultisig; } // @notice Get current unix time stamp function getNow() constant internal returns (uint) { return now; } // @notice If crowdsale is unsuccessful, investors can claim refunds here function claimRefund() only_finalized_sale public { require(!minGoalReached()); saleWallet.refund(msg.sender); } // @notice Check minimum goal for 1st stage function minGoalReached() public view returns (bool) { return totalCollected >= minGoal; } // @notice Check the main goal for 10th stage function goalReached() public view returns (bool) { return totalCollected >= goal; } }
44,049
101
// fix governance delegate bug
_moveDelegates(_delegates[sender], _delegates[recipient], amount); return super.transferFrom(sender, recipient, amount);
_moveDelegates(_delegates[sender], _delegates[recipient], amount); return super.transferFrom(sender, recipient, amount);
12,573
4
// Individual delegation data of a delegator in a pool. /
struct Delegation { uint256 shares; // Shares owned by a delegator in the pool uint256 tokensLocked; // Tokens locked for undelegation uint256 tokensLockedUntil; // Block when locked tokens can be withdrawn }
struct Delegation { uint256 shares; // Shares owned by a delegator in the pool uint256 tokensLocked; // Tokens locked for undelegation uint256 tokensLockedUntil; // Block when locked tokens can be withdrawn }
48,232
193
// Internal function to decrease the allowance by a given decrement owner Token owner's address spender Spender's address decrement Amount of decrease /
function _decreaseAllowance( address owner, address spender, uint256 decrement
function _decreaseAllowance( address owner, address spender, uint256 decrement
23,155
3
// Return `true` if the account belongs to the admin role.
function isAdmin(address account) public virtual view returns (bool) { return hasRole(account, ADMIN_ROLE_ID); }
function isAdmin(address account) public virtual view returns (bool) { return hasRole(account, ADMIN_ROLE_ID); }
48,884
467
// Mapping if character trait has been removed
mapping(uint256 => bool) internal _removedTraitsMap;
mapping(uint256 => bool) internal _removedTraitsMap;
5,744
5
// Meta transaction (gasless) module. Useful for to provide UX where the user does not pay gas for token exchangeTo follow OpenZeppelin, this contract does not implement the functions init & init_unchained.() /
abstract contract MetaTxModule is ERC2771ContextUpgradeable { /// @custom:oz-upgrades-unsafe-allow constructor constructor( address trustedForwarder ) ERC2771ContextUpgradeable(trustedForwarder) { // Nothing to do } function _msgSender() internal view virtual override returns (address sender) { return ERC2771ContextUpgradeable._msgSender(); } function _msgData() internal view virtual override returns (bytes calldata) { return ERC2771ContextUpgradeable._msgData(); } uint256[50] private __gap; }
abstract contract MetaTxModule is ERC2771ContextUpgradeable { /// @custom:oz-upgrades-unsafe-allow constructor constructor( address trustedForwarder ) ERC2771ContextUpgradeable(trustedForwarder) { // Nothing to do } function _msgSender() internal view virtual override returns (address sender) { return ERC2771ContextUpgradeable._msgSender(); } function _msgData() internal view virtual override returns (bytes calldata) { return ERC2771ContextUpgradeable._msgData(); } uint256[50] private __gap; }
18,455
33
// Make sure the result is less than 2^256. Also prevents denominator == 0.
require(denominator > prod1);
require(denominator > prod1);
47,876
217
// Increment deposit.
addressToGoldDeposit[_to] += _amount;
addressToGoldDeposit[_to] += _amount;
12,023
64
// Broker Contract
contract Broker is ERC721Holder { using TokenDetArrayLib for TokenDetArrayLib.TokenDets; // events event Bid( address indexed collection, uint256 indexed tokenId, address indexed seller, address bidder, uint256 amouont, uint256 time ); event Buy( address indexed collection, uint256 tokenId, address indexed seller, address indexed buyer, uint256 amount, uint256 time ); event Collect( address indexed collection, uint256 indexed tokenId, address indexed seller, address buyer, address collector, uint256 time ); event OnSale( address indexed collection, uint256 indexed tokenId, address indexed seller, uint256 auctionType, uint256 amount, uint256 time ); event PriceUpdated( address indexed collection, uint256 indexed tokenId, address indexed seller, uint256 auctionType, uint256 oldAmount, uint256 amount, uint256 time ); event OffSale( address indexed collection, uint256 indexed tokenId, address indexed seller, uint256 time ); address owner; uint16 public brokerage; mapping(address => mapping(uint256 => bool)) tokenOpenForSale; mapping(address => TokenDetArrayLib.TokenDets) tokensForSalePerUser; TokenDetArrayLib.TokenDets fixedPriceTokens; TokenDetArrayLib.TokenDets auctionTokens; //auction type : // 1 : only direct buy // 2 : only bid // 3 : both buy and bid struct auction { address payable lastOwner; uint256 currentBid; address payable highestBidder; uint256 auctionType; uint256 startingPrice; uint256 buyPrice; bool buyer; uint256 startingTime; uint256 closingTime; } mapping(address => mapping(uint256 => auction)) public auctions; TokenDetArrayLib.TokenDets tokensForSale; constructor(uint16 _brokerage) public { owner = msg.sender; brokerage = _brokerage; } function getTokensForSale() public view returns (TokenDetArrayLib.TokenDet[] memory) { return tokensForSale.array; } function getFixedPriceTokensForSale() public view returns (TokenDetArrayLib.TokenDet[] memory) { return fixedPriceTokens.array; } function getAuctionTokensForSale() public view returns (TokenDetArrayLib.TokenDet[] memory) { return auctionTokens.array; } function getTokensForSalePerUser(address _user) public view returns (TokenDetArrayLib.TokenDet[] memory) { return tokensForSalePerUser[_user].array; } function setBrokerage(uint16 _brokerage) public onlyOwner { brokerage = _brokerage; } function bid(uint256 tokenID, address _mintableToken) public payable { MintableToken Token = MintableToken(_mintableToken); require( tokenOpenForSale[_mintableToken][tokenID] == true, "Token Not For Sale" ); require( msg.value > auctions[_mintableToken][tokenID].currentBid, "Insufficient Payment" ); require( block.timestamp < auctions[_mintableToken][tokenID].closingTime, "Auction Time Over!" ); require( auctions[_mintableToken][tokenID].auctionType != 1, "Auction Not For Bid" ); if (auctions[_mintableToken][tokenID].buyer == true) { auctions[_mintableToken][tokenID].highestBidder.transfer( auctions[_mintableToken][tokenID].currentBid ); } Token.safeTransferFrom(Token.ownerOf(tokenID), address(this), tokenID); auctions[_mintableToken][tokenID].currentBid = msg.value; auctions[_mintableToken][tokenID].buyer = true; auctions[_mintableToken][tokenID].highestBidder = msg.sender; // Bid event emit Bid( _mintableToken, tokenID, auctions[_mintableToken][tokenID].lastOwner, msg.sender, msg.value, block.timestamp ); } function collect(uint256 tokenID, address _mintableToken) public { MintableToken Token = MintableToken(_mintableToken); // Check expiry time require( block.timestamp > auctions[_mintableToken][tokenID].closingTime, "Auction Not Over!" ); // Get seller of the NFT address payable lastOwner2 = auctions[_mintableToken][tokenID] .lastOwner; // Check if this auction had even a single bid if (auctions[_mintableToken][tokenID].buyer == true){ // Get royality and creator of NFT from collection uint256 royalities = Token.royalities(tokenID); address payable creator = Token.creators(tokenID); // auctions[_mintableToken][tokenID].buyPrice = uint256(0); // NFT transfer Token.safeTransferFrom( Token.ownerOf(tokenID), auctions[_mintableToken][tokenID].highestBidder, tokenID ); // Royality transfer creator.transfer( (royalities * auctions[_mintableToken][tokenID].currentBid) / 10000 ); // Fund transfer after brockerage and royality charges lastOwner2.transfer( ((10000 - royalities - brokerage) * auctions[_mintableToken][tokenID].currentBid) / 10000 ); // Buy event emit Buy( _mintableToken, tokenID, lastOwner2, auctions[_mintableToken][tokenID].highestBidder, auctions[_mintableToken][tokenID].currentBid, block.timestamp ); } // Disabling the on sale status tokenOpenForSale[_mintableToken][tokenID] = false; // Collect event emit Collect( _mintableToken, tokenID, lastOwner2, auctions[_mintableToken][tokenID].highestBidder, msg.sender, block.timestamp ); // Remove from sale list tokensForSale.removeTokenDet(_mintableToken,tokenID); // Remove from sale per user list tokensForSalePerUser[lastOwner2].removeTokenDet(_mintableToken,tokenID); // Remove form auctions list auctionTokens.removeTokenDet(_mintableToken,tokenID); // Delete the auction details delete auctions[_mintableToken][tokenID]; } function buy(uint256 tokenID, address _mintableToken) public payable { MintableToken Token = MintableToken(_mintableToken); require( tokenOpenForSale[_mintableToken][tokenID] == true, "Token Not For Sale" ); require( msg.value >= auctions[_mintableToken][tokenID].buyPrice, "Insufficient Payment" ); require( auctions[_mintableToken][tokenID].auctionType != 2, "Auction for Bid only!" ); address payable lastOwner2 = auctions[_mintableToken][tokenID] .lastOwner; uint256 royalities = Token.royalities(tokenID); address payable creator = Token.creators(tokenID); tokenOpenForSale[_mintableToken][tokenID] = false; auctions[_mintableToken][tokenID].buyer = true; auctions[_mintableToken][tokenID].highestBidder = msg.sender; auctions[_mintableToken][tokenID].currentBid = auctions[_mintableToken][ tokenID ].buyPrice; Token.safeTransferFrom( Token.ownerOf(tokenID), auctions[_mintableToken][tokenID].highestBidder, tokenID ); creator.transfer( (royalities * auctions[_mintableToken][tokenID].currentBid) / 10000 ); lastOwner2.transfer( ((10000 - royalities - brokerage) * auctions[_mintableToken][tokenID].currentBid) / 10000 ); // Buy event emit Buy( _mintableToken, tokenID, lastOwner2, msg.sender, auctions[_mintableToken][tokenID].buyPrice, block.timestamp ); tokensForSale.removeTokenDet(_mintableToken,tokenID); tokensForSalePerUser[lastOwner2].removeTokenDet(_mintableToken,tokenID); fixedPriceTokens.removeTokenDet(_mintableToken,tokenID); } function withdraw() public onlyOwner { msg.sender.transfer(address(this).balance); } function putOnSale( uint256 _tokenID, uint256 _startingPrice, uint256 _auctionType, uint256 _buyPrice, uint256 _duration, address _mintableToken ) public { MintableToken Token = MintableToken(_mintableToken); require(Token.ownerOf(_tokenID) == msg.sender, "Permission Denied"); require( Token.getApproved(_tokenID) == address(this), "Broker Not approved" ); // Allow to put on sale to already on sale NFT \ // only if it was on auction and have 0 bids and auction is over if (tokenOpenForSale[_mintableToken][_tokenID] == true) { require( auctions[_mintableToken][_tokenID].auctionType == 2 && auctions[_mintableToken][_tokenID].buyer == false && block.timestamp > auctions[_mintableToken][_tokenID].closingTime, "This NFT is already on sale." ); } auction memory newAuction = auction( msg.sender, _startingPrice, address(0), _auctionType, _startingPrice, _buyPrice, false, block.timestamp, block.timestamp + _duration ); auctions[_mintableToken][_tokenID] = newAuction; // Store data in all mappings if adding fresh token on sale if (tokenOpenForSale[_mintableToken][_tokenID] == false){ tokenOpenForSale[_mintableToken][_tokenID] = true; tokensForSale.addTokenDet(_mintableToken, _tokenID); tokensForSalePerUser[msg.sender].addTokenDet(_mintableToken, _tokenID); // Add token to fixedPrice on Timed list if (_auctionType == 1) { fixedPriceTokens.addTokenDet(_mintableToken, _tokenID); } else if (_auctionType == 2) { auctionTokens.addTokenDet(_mintableToken, _tokenID); } } // OnSale event emit OnSale( _mintableToken, _tokenID, msg.sender, _auctionType, _auctionType == 1 ? _buyPrice : _startingPrice, block.timestamp ); } function updatePrice(uint256 tokenID, address _mintableToken, uint256 _newPrice) public { MintableToken Token = MintableToken(_mintableToken); // Sender will be owner only if no have bidded on auction. require( Token.ownerOf(tokenID) == msg.sender, "You must be owner and Token should not have any bid" ); require( tokenOpenForSale[_mintableToken][tokenID] == true, "Token Must be on sale to change price" ); if (auctions[_mintableToken][tokenID].auctionType == 2){ require( block.timestamp < auctions[_mintableToken][tokenID].closingTime, "Auction Time Over!" ); } // Trigger event PriceUpdated with Old and new price emit PriceUpdated( _mintableToken, tokenID, auctions[_mintableToken][tokenID].lastOwner, auctions[_mintableToken][tokenID].auctionType, auctions[_mintableToken][tokenID].auctionType == 1 ? auctions[_mintableToken][tokenID].buyPrice : auctions[_mintableToken][tokenID].startingPrice, _newPrice, block.timestamp ); // Update Price if (auctions[_mintableToken][tokenID].auctionType == 1){ auctions[_mintableToken][tokenID].buyPrice = _newPrice; } else{ auctions[_mintableToken][tokenID].startingPrice = _newPrice; auctions[_mintableToken][tokenID].currentBid = _newPrice; } } function putSaleOff(uint256 tokenID, address _mintableToken) public { MintableToken Token = MintableToken(_mintableToken); require(Token.ownerOf(tokenID) == msg.sender, "Permission Denied"); auctions[_mintableToken][tokenID].buyPrice = uint256(0); tokenOpenForSale[_mintableToken][tokenID] = false; // OffSale event emit OffSale(_mintableToken, tokenID, msg.sender, block.timestamp); tokensForSale.removeTokenDet(_mintableToken, tokenID); tokensForSalePerUser[msg.sender].removeTokenDet(_mintableToken, tokenID); // Remove token from list if (auctions[_mintableToken][tokenID].auctionType == 1) { fixedPriceTokens.removeTokenDet(_mintableToken, tokenID); } else if (auctions[_mintableToken][tokenID].auctionType == 2) { auctionTokens.removeTokenDet(_mintableToken, tokenID); } } function getOnSaleStatus(address _mintableToken, uint256 tokenID) public view returns (bool) { return tokenOpenForSale[_mintableToken][tokenID]; } modifier onlyOwner() { require(owner == msg.sender, "Ownable: caller is not the owner"); _; } function() external payable { //call your function here / implement your actions } }
contract Broker is ERC721Holder { using TokenDetArrayLib for TokenDetArrayLib.TokenDets; // events event Bid( address indexed collection, uint256 indexed tokenId, address indexed seller, address bidder, uint256 amouont, uint256 time ); event Buy( address indexed collection, uint256 tokenId, address indexed seller, address indexed buyer, uint256 amount, uint256 time ); event Collect( address indexed collection, uint256 indexed tokenId, address indexed seller, address buyer, address collector, uint256 time ); event OnSale( address indexed collection, uint256 indexed tokenId, address indexed seller, uint256 auctionType, uint256 amount, uint256 time ); event PriceUpdated( address indexed collection, uint256 indexed tokenId, address indexed seller, uint256 auctionType, uint256 oldAmount, uint256 amount, uint256 time ); event OffSale( address indexed collection, uint256 indexed tokenId, address indexed seller, uint256 time ); address owner; uint16 public brokerage; mapping(address => mapping(uint256 => bool)) tokenOpenForSale; mapping(address => TokenDetArrayLib.TokenDets) tokensForSalePerUser; TokenDetArrayLib.TokenDets fixedPriceTokens; TokenDetArrayLib.TokenDets auctionTokens; //auction type : // 1 : only direct buy // 2 : only bid // 3 : both buy and bid struct auction { address payable lastOwner; uint256 currentBid; address payable highestBidder; uint256 auctionType; uint256 startingPrice; uint256 buyPrice; bool buyer; uint256 startingTime; uint256 closingTime; } mapping(address => mapping(uint256 => auction)) public auctions; TokenDetArrayLib.TokenDets tokensForSale; constructor(uint16 _brokerage) public { owner = msg.sender; brokerage = _brokerage; } function getTokensForSale() public view returns (TokenDetArrayLib.TokenDet[] memory) { return tokensForSale.array; } function getFixedPriceTokensForSale() public view returns (TokenDetArrayLib.TokenDet[] memory) { return fixedPriceTokens.array; } function getAuctionTokensForSale() public view returns (TokenDetArrayLib.TokenDet[] memory) { return auctionTokens.array; } function getTokensForSalePerUser(address _user) public view returns (TokenDetArrayLib.TokenDet[] memory) { return tokensForSalePerUser[_user].array; } function setBrokerage(uint16 _brokerage) public onlyOwner { brokerage = _brokerage; } function bid(uint256 tokenID, address _mintableToken) public payable { MintableToken Token = MintableToken(_mintableToken); require( tokenOpenForSale[_mintableToken][tokenID] == true, "Token Not For Sale" ); require( msg.value > auctions[_mintableToken][tokenID].currentBid, "Insufficient Payment" ); require( block.timestamp < auctions[_mintableToken][tokenID].closingTime, "Auction Time Over!" ); require( auctions[_mintableToken][tokenID].auctionType != 1, "Auction Not For Bid" ); if (auctions[_mintableToken][tokenID].buyer == true) { auctions[_mintableToken][tokenID].highestBidder.transfer( auctions[_mintableToken][tokenID].currentBid ); } Token.safeTransferFrom(Token.ownerOf(tokenID), address(this), tokenID); auctions[_mintableToken][tokenID].currentBid = msg.value; auctions[_mintableToken][tokenID].buyer = true; auctions[_mintableToken][tokenID].highestBidder = msg.sender; // Bid event emit Bid( _mintableToken, tokenID, auctions[_mintableToken][tokenID].lastOwner, msg.sender, msg.value, block.timestamp ); } function collect(uint256 tokenID, address _mintableToken) public { MintableToken Token = MintableToken(_mintableToken); // Check expiry time require( block.timestamp > auctions[_mintableToken][tokenID].closingTime, "Auction Not Over!" ); // Get seller of the NFT address payable lastOwner2 = auctions[_mintableToken][tokenID] .lastOwner; // Check if this auction had even a single bid if (auctions[_mintableToken][tokenID].buyer == true){ // Get royality and creator of NFT from collection uint256 royalities = Token.royalities(tokenID); address payable creator = Token.creators(tokenID); // auctions[_mintableToken][tokenID].buyPrice = uint256(0); // NFT transfer Token.safeTransferFrom( Token.ownerOf(tokenID), auctions[_mintableToken][tokenID].highestBidder, tokenID ); // Royality transfer creator.transfer( (royalities * auctions[_mintableToken][tokenID].currentBid) / 10000 ); // Fund transfer after brockerage and royality charges lastOwner2.transfer( ((10000 - royalities - brokerage) * auctions[_mintableToken][tokenID].currentBid) / 10000 ); // Buy event emit Buy( _mintableToken, tokenID, lastOwner2, auctions[_mintableToken][tokenID].highestBidder, auctions[_mintableToken][tokenID].currentBid, block.timestamp ); } // Disabling the on sale status tokenOpenForSale[_mintableToken][tokenID] = false; // Collect event emit Collect( _mintableToken, tokenID, lastOwner2, auctions[_mintableToken][tokenID].highestBidder, msg.sender, block.timestamp ); // Remove from sale list tokensForSale.removeTokenDet(_mintableToken,tokenID); // Remove from sale per user list tokensForSalePerUser[lastOwner2].removeTokenDet(_mintableToken,tokenID); // Remove form auctions list auctionTokens.removeTokenDet(_mintableToken,tokenID); // Delete the auction details delete auctions[_mintableToken][tokenID]; } function buy(uint256 tokenID, address _mintableToken) public payable { MintableToken Token = MintableToken(_mintableToken); require( tokenOpenForSale[_mintableToken][tokenID] == true, "Token Not For Sale" ); require( msg.value >= auctions[_mintableToken][tokenID].buyPrice, "Insufficient Payment" ); require( auctions[_mintableToken][tokenID].auctionType != 2, "Auction for Bid only!" ); address payable lastOwner2 = auctions[_mintableToken][tokenID] .lastOwner; uint256 royalities = Token.royalities(tokenID); address payable creator = Token.creators(tokenID); tokenOpenForSale[_mintableToken][tokenID] = false; auctions[_mintableToken][tokenID].buyer = true; auctions[_mintableToken][tokenID].highestBidder = msg.sender; auctions[_mintableToken][tokenID].currentBid = auctions[_mintableToken][ tokenID ].buyPrice; Token.safeTransferFrom( Token.ownerOf(tokenID), auctions[_mintableToken][tokenID].highestBidder, tokenID ); creator.transfer( (royalities * auctions[_mintableToken][tokenID].currentBid) / 10000 ); lastOwner2.transfer( ((10000 - royalities - brokerage) * auctions[_mintableToken][tokenID].currentBid) / 10000 ); // Buy event emit Buy( _mintableToken, tokenID, lastOwner2, msg.sender, auctions[_mintableToken][tokenID].buyPrice, block.timestamp ); tokensForSale.removeTokenDet(_mintableToken,tokenID); tokensForSalePerUser[lastOwner2].removeTokenDet(_mintableToken,tokenID); fixedPriceTokens.removeTokenDet(_mintableToken,tokenID); } function withdraw() public onlyOwner { msg.sender.transfer(address(this).balance); } function putOnSale( uint256 _tokenID, uint256 _startingPrice, uint256 _auctionType, uint256 _buyPrice, uint256 _duration, address _mintableToken ) public { MintableToken Token = MintableToken(_mintableToken); require(Token.ownerOf(_tokenID) == msg.sender, "Permission Denied"); require( Token.getApproved(_tokenID) == address(this), "Broker Not approved" ); // Allow to put on sale to already on sale NFT \ // only if it was on auction and have 0 bids and auction is over if (tokenOpenForSale[_mintableToken][_tokenID] == true) { require( auctions[_mintableToken][_tokenID].auctionType == 2 && auctions[_mintableToken][_tokenID].buyer == false && block.timestamp > auctions[_mintableToken][_tokenID].closingTime, "This NFT is already on sale." ); } auction memory newAuction = auction( msg.sender, _startingPrice, address(0), _auctionType, _startingPrice, _buyPrice, false, block.timestamp, block.timestamp + _duration ); auctions[_mintableToken][_tokenID] = newAuction; // Store data in all mappings if adding fresh token on sale if (tokenOpenForSale[_mintableToken][_tokenID] == false){ tokenOpenForSale[_mintableToken][_tokenID] = true; tokensForSale.addTokenDet(_mintableToken, _tokenID); tokensForSalePerUser[msg.sender].addTokenDet(_mintableToken, _tokenID); // Add token to fixedPrice on Timed list if (_auctionType == 1) { fixedPriceTokens.addTokenDet(_mintableToken, _tokenID); } else if (_auctionType == 2) { auctionTokens.addTokenDet(_mintableToken, _tokenID); } } // OnSale event emit OnSale( _mintableToken, _tokenID, msg.sender, _auctionType, _auctionType == 1 ? _buyPrice : _startingPrice, block.timestamp ); } function updatePrice(uint256 tokenID, address _mintableToken, uint256 _newPrice) public { MintableToken Token = MintableToken(_mintableToken); // Sender will be owner only if no have bidded on auction. require( Token.ownerOf(tokenID) == msg.sender, "You must be owner and Token should not have any bid" ); require( tokenOpenForSale[_mintableToken][tokenID] == true, "Token Must be on sale to change price" ); if (auctions[_mintableToken][tokenID].auctionType == 2){ require( block.timestamp < auctions[_mintableToken][tokenID].closingTime, "Auction Time Over!" ); } // Trigger event PriceUpdated with Old and new price emit PriceUpdated( _mintableToken, tokenID, auctions[_mintableToken][tokenID].lastOwner, auctions[_mintableToken][tokenID].auctionType, auctions[_mintableToken][tokenID].auctionType == 1 ? auctions[_mintableToken][tokenID].buyPrice : auctions[_mintableToken][tokenID].startingPrice, _newPrice, block.timestamp ); // Update Price if (auctions[_mintableToken][tokenID].auctionType == 1){ auctions[_mintableToken][tokenID].buyPrice = _newPrice; } else{ auctions[_mintableToken][tokenID].startingPrice = _newPrice; auctions[_mintableToken][tokenID].currentBid = _newPrice; } } function putSaleOff(uint256 tokenID, address _mintableToken) public { MintableToken Token = MintableToken(_mintableToken); require(Token.ownerOf(tokenID) == msg.sender, "Permission Denied"); auctions[_mintableToken][tokenID].buyPrice = uint256(0); tokenOpenForSale[_mintableToken][tokenID] = false; // OffSale event emit OffSale(_mintableToken, tokenID, msg.sender, block.timestamp); tokensForSale.removeTokenDet(_mintableToken, tokenID); tokensForSalePerUser[msg.sender].removeTokenDet(_mintableToken, tokenID); // Remove token from list if (auctions[_mintableToken][tokenID].auctionType == 1) { fixedPriceTokens.removeTokenDet(_mintableToken, tokenID); } else if (auctions[_mintableToken][tokenID].auctionType == 2) { auctionTokens.removeTokenDet(_mintableToken, tokenID); } } function getOnSaleStatus(address _mintableToken, uint256 tokenID) public view returns (bool) { return tokenOpenForSale[_mintableToken][tokenID]; } modifier onlyOwner() { require(owner == msg.sender, "Ownable: caller is not the owner"); _; } function() external payable { //call your function here / implement your actions } }
51,884
252
// Calculate the interest earned by each party for keeping `stream.balance` in the smart contract. //Calculate the net withdrawal amount by subtracting `senderInterest` and `sablierInterest`.Because the decimal points are lost when we truncate Exponentials, the recipient will implicitly earn`recipientInterest` plus a tiny-weeny amount of interest, max 2e-8 in cToken denomination. /
(vars.mathErr, vars.amountWithoutSenderInterest) = subUInt(amount, senderInterest); require(vars.mathErr == MathError.NO_ERROR, "amount without sender interest calculation error"); (vars.mathErr, vars.netWithdrawalAmount) = subUInt(vars.amountWithoutSenderInterest, sablierInterest); require(vars.mathErr == MathError.NO_ERROR, "net withdrawal amount calculation error");
(vars.mathErr, vars.amountWithoutSenderInterest) = subUInt(amount, senderInterest); require(vars.mathErr == MathError.NO_ERROR, "amount without sender interest calculation error"); (vars.mathErr, vars.netWithdrawalAmount) = subUInt(vars.amountWithoutSenderInterest, sablierInterest); require(vars.mathErr == MathError.NO_ERROR, "net withdrawal amount calculation error");
8,215
116
// This function allows owner to set a new fee. _fee - The feeAccess Control: Only Owner /
function setFee(uint256 _fee) external onlyOwner() { require(_fee <= MAX_FEE_PCNT, "Max fee exceeded"); feePcnt = _fee; }
function setFee(uint256 _fee) external onlyOwner() { require(_fee <= MAX_FEE_PCNT, "Max fee exceeded"); feePcnt = _fee; }
8,106
565
// Allows the grant manager to withdraw revoked tokens./Will withdraw as many of the revoked tokens as possible/ without pushing the grant contract into a token deficit./ If the grantee has staked more tokens than the unlocked amount,/ those tokens will remain in the grant until undelegated and returned,/ after which they can be withdrawn by calling `withdrawRevoked` again./_id Grant ID.
function withdrawRevoked(uint256 _id) public { Grant storage grant = grants[_id]; require( grant.grantManager == msg.sender, "Only grant manager can withdraw revoked tokens." ); uint256 revoked = grant.revokedAmount; uint256 revokedWithdrawn = grant.revokedWithdrawn; require(revokedWithdrawn < revoked, "All revoked tokens withdrawn."); uint256 revokedRemaining = revoked.sub(revokedWithdrawn); uint256 totalAmount = grant.amount; uint256 staked = grant.staked; uint256 granteeWithdrawn = grant.withdrawn; uint256 remainingPresentInGrant = totalAmount.sub(staked).sub(revokedWithdrawn).sub(granteeWithdrawn); require(remainingPresentInGrant > 0, "No revoked tokens withdrawable."); uint256 amountToWithdraw = remainingPresentInGrant < revokedRemaining ? remainingPresentInGrant : revokedRemaining; token.safeTransfer(msg.sender, amountToWithdraw); grant.revokedWithdrawn += amountToWithdraw; }
function withdrawRevoked(uint256 _id) public { Grant storage grant = grants[_id]; require( grant.grantManager == msg.sender, "Only grant manager can withdraw revoked tokens." ); uint256 revoked = grant.revokedAmount; uint256 revokedWithdrawn = grant.revokedWithdrawn; require(revokedWithdrawn < revoked, "All revoked tokens withdrawn."); uint256 revokedRemaining = revoked.sub(revokedWithdrawn); uint256 totalAmount = grant.amount; uint256 staked = grant.staked; uint256 granteeWithdrawn = grant.withdrawn; uint256 remainingPresentInGrant = totalAmount.sub(staked).sub(revokedWithdrawn).sub(granteeWithdrawn); require(remainingPresentInGrant > 0, "No revoked tokens withdrawable."); uint256 amountToWithdraw = remainingPresentInGrant < revokedRemaining ? remainingPresentInGrant : revokedRemaining; token.safeTransfer(msg.sender, amountToWithdraw); grant.revokedWithdrawn += amountToWithdraw; }
7,067
14
// the actual ETH/USD conversation rate, after adjusting the extra 0s.
return ethAmountInUsd;
return ethAmountInUsd;
12,974
17
// Free Mints
mapping(address => uint256) freeMints;
mapping(address => uint256) freeMints;
11,503
165
// Returns the total amount of tokens minted in the contract. /
function _totalMinted() internal view virtual returns (uint256) { // Counter underflow is impossible as `_currentIndex` does not decrement, // and it is initialized to `_startTokenId()`. unchecked { return _currentIndex - _startTokenId(); } }
function _totalMinted() internal view virtual returns (uint256) { // Counter underflow is impossible as `_currentIndex` does not decrement, // and it is initialized to `_startTokenId()`. unchecked { return _currentIndex - _startTokenId(); } }
525
72
// note we still don't put timestamp back into array (is this an issue? (shouldn't be))
_request.finalValues[disp.disputeUintVars[keccak256("timestamp")]] = disp.disputeUintVars[keccak256("value")];
_request.finalValues[disp.disputeUintVars[keccak256("timestamp")]] = disp.disputeUintVars[keccak256("value")];
55,376
115
// checking if appointee has rights to cast a vote
require(_sip.appointees[msg.sender] , 'should be appointee to cast vote' );
require(_sip.appointees[msg.sender] , 'should be appointee to cast vote' );
24,164
17
// Used when multiple can call./
modifier onlyModules(bytes32 _moduleOne, bytes32 _moduleTwo) { string memory message = string(abi.encodePacked("only module ", _moduleOne.toString()," or ", _moduleTwo.toString()," can call this function")); require(msg.sender == getModule(_moduleOne) || msg.sender == getModule(_moduleTwo), message); _; }
modifier onlyModules(bytes32 _moduleOne, bytes32 _moduleTwo) { string memory message = string(abi.encodePacked("only module ", _moduleOne.toString()," or ", _moduleTwo.toString()," can call this function")); require(msg.sender == getModule(_moduleOne) || msg.sender == getModule(_moduleTwo), message); _; }
27,330
50
// Mints batches of NFTs. Limited to maximum number of NFTs that can be minted for this drop. Needs to be called in tokenId sequence. creatorWallet The wallet address of the NFT creator. startId The tokenId from which to start batch mint. length The total number of NFTs to mint starting from the startId. recipient Optional parameter, to send the token to a recipient right after minting. /
function batchMint(address creatorWallet, uint256 startId, uint256 length, address recipient) public onlyOwner { require(!getMintingClosed(), "CXIP: minting is now closed"); require(_allTokens.length + length <= getTokenLimit(), "CXIP: over token limit"); require(isIdentityWallet(creatorWallet), "CXIP: creator not in identity"); bool hasRecipient = !Address.isZero(recipient); uint256 tokenId; for (uint256 i = 0; i < length; i++) { tokenId = (startId + i); if (hasRecipient) { require(!_exists(tokenId), "CXIP: token already exists"); emit Transfer(address(0), creatorWallet, tokenId); emit Transfer(creatorWallet, recipient, tokenId); _tokenOwner[tokenId] = recipient; _addTokenToOwnerEnumeration(recipient, tokenId); } else { _mint(creatorWallet, tokenId); } } if (_allTokens.length == getTokenLimit()) { setMintingClosed(); } }
function batchMint(address creatorWallet, uint256 startId, uint256 length, address recipient) public onlyOwner { require(!getMintingClosed(), "CXIP: minting is now closed"); require(_allTokens.length + length <= getTokenLimit(), "CXIP: over token limit"); require(isIdentityWallet(creatorWallet), "CXIP: creator not in identity"); bool hasRecipient = !Address.isZero(recipient); uint256 tokenId; for (uint256 i = 0; i < length; i++) { tokenId = (startId + i); if (hasRecipient) { require(!_exists(tokenId), "CXIP: token already exists"); emit Transfer(address(0), creatorWallet, tokenId); emit Transfer(creatorWallet, recipient, tokenId); _tokenOwner[tokenId] = recipient; _addTokenToOwnerEnumeration(recipient, tokenId); } else { _mint(creatorWallet, tokenId); } } if (_allTokens.length == getTokenLimit()) { setMintingClosed(); } }
29,384
290
// UPDATE STORAGE AFTER
{ uint128 stratTotalUnderlying = getStrategyBalance();
{ uint128 stratTotalUnderlying = getStrategyBalance();
34,298
208
// get current quote/base asset reserve.return (quote asset reserve, base asset reserve) /
function getReserve() external view override returns (Decimal.decimal memory, Decimal.decimal memory) { return (quoteAssetReserve, baseAssetReserve); }
function getReserve() external view override returns (Decimal.decimal memory, Decimal.decimal memory) { return (quoteAssetReserve, baseAssetReserve); }
6,499
282
// Parent NFT Contractmainnet addressaddress public nftAddress = 0x1cb1a5e65610aeff2551a50f76a87a7d3fb649c6;rinkeby address
address public nftAddress = 0x70BC4cCb9bC9eF1B7E9dc465a38EEbc5d73740FB; nftInterface nftContract = nftInterface(nftAddress);
address public nftAddress = 0x70BC4cCb9bC9eF1B7E9dc465a38EEbc5d73740FB; nftInterface nftContract = nftInterface(nftAddress);
72,348
0
// Enum for project state
enum State { Inactive, Active, Completed }
enum State { Inactive, Active, Completed }
2,983
57
// Allows token holders to vote_disputeId is the dispute id_supportsDispute is the vote (true=the dispute has basis false = vote against dispute)/
function vote(TellorStorage.TellorStorageStruct storage self, uint256 _disputeId, bool _supportsDispute) public { TellorStorage.Dispute storage disp = self.disputesById[_disputeId]; //Get the voteWeight or the balance of the user at the time/blockNumber the disupte began uint256 voteWeight = TellorTransfer.balanceOfAt(self, msg.sender, disp.disputeUintVars[keccak256("blockNumber")]); //Require that the msg.sender has not voted require(disp.voted[msg.sender] != true, "Sender has already voted"); //Requre that the user had a balance >0 at time/blockNumber the disupte began require(voteWeight != 0, "User balance is 0"); //ensures miners that are under dispute cannot vote require(self.stakerDetails[msg.sender].currentStatus != 3, "Miner is under dispute"); //Update user voting status to true disp.voted[msg.sender] = true; //Update the number of votes for the dispute disp.disputeUintVars[keccak256("numberOfVotes")] += 1; //If the user supports the dispute increase the tally for the dispute by the voteWeight //otherwise decrease it if (_supportsDispute) { disp.tally = disp.tally.add(int256(voteWeight)); } else { disp.tally = disp.tally.sub(int256(voteWeight)); } //Let the network know the user has voted on the dispute and their casted vote emit Voted(_disputeId, _supportsDispute, msg.sender, voteWeight); }
function vote(TellorStorage.TellorStorageStruct storage self, uint256 _disputeId, bool _supportsDispute) public { TellorStorage.Dispute storage disp = self.disputesById[_disputeId]; //Get the voteWeight or the balance of the user at the time/blockNumber the disupte began uint256 voteWeight = TellorTransfer.balanceOfAt(self, msg.sender, disp.disputeUintVars[keccak256("blockNumber")]); //Require that the msg.sender has not voted require(disp.voted[msg.sender] != true, "Sender has already voted"); //Requre that the user had a balance >0 at time/blockNumber the disupte began require(voteWeight != 0, "User balance is 0"); //ensures miners that are under dispute cannot vote require(self.stakerDetails[msg.sender].currentStatus != 3, "Miner is under dispute"); //Update user voting status to true disp.voted[msg.sender] = true; //Update the number of votes for the dispute disp.disputeUintVars[keccak256("numberOfVotes")] += 1; //If the user supports the dispute increase the tally for the dispute by the voteWeight //otherwise decrease it if (_supportsDispute) { disp.tally = disp.tally.add(int256(voteWeight)); } else { disp.tally = disp.tally.sub(int256(voteWeight)); } //Let the network know the user has voted on the dispute and their casted vote emit Voted(_disputeId, _supportsDispute, msg.sender, voteWeight); }
55,361
770
// Create a new instance of an app linked to this kernelCreate a new upgradeable instance of `_appId` app linked to the Kernel, setting its code to `_appBase`_appId Identifier for app_appBase Address of the app's base implementation return AppProxy instance/
function newAppInstance(bytes32 _appId, address _appBase) public auth(APP_MANAGER_ROLE, arr(KERNEL_APP_BASES_NAMESPACE, _appId)) returns (ERCProxy appProxy)
function newAppInstance(bytes32 _appId, address _appBase) public auth(APP_MANAGER_ROLE, arr(KERNEL_APP_BASES_NAMESPACE, _appId)) returns (ERCProxy appProxy)
62,879
14
// record user deposit amount
pool.amount = pool.amount + amount; user.amount = user.amount + amount; accDeposit = accDeposit + amount; emit Deposit(msg.sender, pid, amount);
pool.amount = pool.amount + amount; user.amount = user.amount + amount; accDeposit = accDeposit + amount; emit Deposit(msg.sender, pid, amount);
41,934
500
// Gets the name of the NFT collection implemented by this contract
function name() external pure override returns (string memory) { return "AnglePerp"; }
function name() external pure override returns (string memory) { return "AnglePerp"; }
30,244
17
// ------------------------------------------------------------------------Total supply------------------------------------------------------------------------
function totalSupply() public override view returns (uint) { return _totalSupply - balances[address(0)]; }
function totalSupply() public override view returns (uint) { return _totalSupply - balances[address(0)]; }
14,484
13
// Check to see if there's already a commitment for this user that is active
Commitment currentForUser = commitments[msg.sender]; if (currentForUser.active == true) throw;
Commitment currentForUser = commitments[msg.sender]; if (currentForUser.active == true) throw;
9,295
451
// Check status, should be `ERROR` (4)
require(loanManager.getStatus(entry.debtId) == Status.ERROR, "collateral: the debt should be in status error"); emit Redeemed(_entryId, _to);
require(loanManager.getStatus(entry.debtId) == Status.ERROR, "collateral: the debt should be in status error"); emit Redeemed(_entryId, _to);
25,706
73
// Overload placeholder - could apply further logic
function xfer(address _from, address _to, uint _amount) internal noReentry returns (bool)
function xfer(address _from, address _to, uint _amount) internal noReentry returns (bool)
53,233
11
// Secondary market royalties in basis points (100 bps = 1%). Royalties use ERC2981 standard and support OpenSea standard.
uint256 public royaltiesBasisPoints;
uint256 public royaltiesBasisPoints;
28,927
81
// default to failure
uint256 returnValue = 0; assembly {
uint256 returnValue = 0; assembly {
42,511
94
// create the PixelDust and keep its address handy
PixelDust token = new PixelDust(name, symbol, 0); token_address = address(token);
PixelDust token = new PixelDust(name, symbol, 0); token_address = address(token);
15,062
35
// Sets cooldown status. Only callable by owner./onoff The boolean to set.
function setCooldownEnabled(bool onoff) external onlyOwner { cooldownEnabled = onoff; }
function setCooldownEnabled(bool onoff) external onlyOwner { cooldownEnabled = onoff; }
16,336
85
// This function disables token transfers for everyone.
function disableTransfers() public onlyWhitelisted { require(transfersEnabled); transfersEnabled = false; }
function disableTransfers() public onlyWhitelisted { require(transfersEnabled); transfersEnabled = false; }
54,557
4
// Errors
error WrongSender(); error WrongSourceAddress(); error InvalidChain();
error WrongSender(); error WrongSourceAddress(); error InvalidChain();
7,904
56
// Burn amount of token from specified account by an operator address /
function burn(address account, uint256 amount) external returns (bool);
function burn(address account, uint256 amount) external returns (bool);
11,259