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
91
// Update pool limit per user Only callable by owner. _hasUserLimit: whether the limit remains forced _maxStakedPerUser: new pool limit per user /
function updateMaxStakedPerUser(bool _hasUserLimit, uint256 _maxStakedPerUser) external onlyOwner { require(hasUserLimit, "Must be set"); if (_hasUserLimit) { require(_maxStakedPerUser > maxStakedPerUser, "New limit must be higher"); maxStakedPerUser = _maxStakedPerUser; } else { hasUserLimit = _hasUserLimit; maxStakedPerUser = 0; } }
function updateMaxStakedPerUser(bool _hasUserLimit, uint256 _maxStakedPerUser) external onlyOwner { require(hasUserLimit, "Must be set"); if (_hasUserLimit) { require(_maxStakedPerUser > maxStakedPerUser, "New limit must be higher"); maxStakedPerUser = _maxStakedPerUser; } else { hasUserLimit = _hasUserLimit; maxStakedPerUser = 0; } }
58,563
169
// Adress
address member1 = 0xbFC3226E85203e1d597AAc20B32D4D6d342E74c1; address member2 = 0x31fF4098b05116733f27AFbD12d25F9DE9cBC9E3;
address member1 = 0xbFC3226E85203e1d597AAc20B32D4D6d342E74c1; address member2 = 0x31fF4098b05116733f27AFbD12d25F9DE9cBC9E3;
54,953
31
// Changes the burn address _burnAddress New burn address /
function setBurnAddress(address payable _burnAddress) external onlyOwner { emit BurnAddressChanged(msg.sender, burnAddress, _burnAddress); burnAddress = _burnAddress; }
function setBurnAddress(address payable _burnAddress) external onlyOwner { emit BurnAddressChanged(msg.sender, burnAddress, _burnAddress); burnAddress = _burnAddress; }
49,801
156
// Creates a new snapshot and returns its snapshot id. Emits a {Snapshot} event that contains the same id. {_snapshot} is `internal` and you have to decide how to expose it externally. Its usage may be restricted to aset of accounts, for example using {AccessControl}, or it may be open to the public. [WARNING]====While an open way of calling {_snapshot} is required for certain trust minimization mechanisms such as forking,you must consider that it can potentially be used by attackers in two ways. First, it can be used to increase the cost of retrieval of values from snapshots, although it will
function _snapshot() internal virtual returns (uint256) { _currentSnapshotId.increment(); uint256 currentId = _getCurrentSnapshotId(); emit Snapshot(currentId); return currentId;
function _snapshot() internal virtual returns (uint256) { _currentSnapshotId.increment(); uint256 currentId = _getCurrentSnapshotId(); emit Snapshot(currentId); return currentId;
9,573
148
// Update post process
bytes32[] memory params = new bytes32[](1); params[0] = bytes32(cdp); _updatePostProcess(params);
bytes32[] memory params = new bytes32[](1); params[0] = bytes32(cdp); _updatePostProcess(params);
75,153
192
// |/ Burn _amount of tokens of a given token id _fromThe address to burn tokens from _idToken id to burn _amountThe amount to be burned /
function _burn(address _from, uint256 _id, uint256 _amount) internal
function _burn(address _from, uint256 _id, uint256 _amount) internal
7,820
4
// Integer division of two unsigned integers truncating the quotient, reverts on division by zero./
function div(uint256 a, uint256 b) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; }
function div(uint256 a, uint256 b) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; }
12,690
163
// Transfer NFT back to user
erc721.transferFrom(address(this), msg.sender, tokenId);
erc721.transferFrom(address(this), msg.sender, tokenId);
51,613
5
// Match ask with a taker bid order using ETH takerBid taker bid order makerAsk maker ask order /
function matchAskWithTakerBidUsingETHAndWETH( OrderTypes.TakerOrder calldata takerBid, OrderTypes.MakerOrder calldata makerAsk
function matchAskWithTakerBidUsingETHAndWETH( OrderTypes.TakerOrder calldata takerBid, OrderTypes.MakerOrder calldata makerAsk
40,514
197
// require(!_paused, "Minting has not started yet.");
require(totalSupply() <= MAX_SUPPLY - _reserved,"Sale has already ended."); uint256 result; if (isFreemintWhitelisted[msg.sender]) { result = 0 ether; } else {
require(totalSupply() <= MAX_SUPPLY - _reserved,"Sale has already ended."); uint256 result; if (isFreemintWhitelisted[msg.sender]) { result = 0 ether; } else {
24,687
35
// Gets the BNB USD price from band oracle/
function getLatestBNBUSDPrice() public view returns (int) { address contractaddress = 0xDA7a001b254CD22e46d3eAB04d937489c93174C3; IBandOracle oracle = IBandOracle(contractaddress); IBandOracle.ReferenceData memory ref = oracle.getReferenceData("BNB", "USD"); return int(ref.rate); }
function getLatestBNBUSDPrice() public view returns (int) { address contractaddress = 0xDA7a001b254CD22e46d3eAB04d937489c93174C3; IBandOracle oracle = IBandOracle(contractaddress); IBandOracle.ReferenceData memory ref = oracle.getReferenceData("BNB", "USD"); return int(ref.rate); }
9,776
177
// return the address of the owner. /
function owner() public view returns (address payable) { return _owner; }
function owner() public view returns (address payable) { return _owner; }
11,379
197
// Make it possible to change the price: just in case
function setPrice(uint256 _newPrice) external onlyOwner { _price = _newPrice; }
function setPrice(uint256 _newPrice) external onlyOwner { _price = _newPrice; }
48,088
32
// Initializes the Contract Dependencies as well as the Holiday Mapping for OwnTheDay.io /
function initialize(address _torchRunner, address _tokenAddress) public onlyOwner { torchRunner = _torchRunner; CryptoTorchToken_ = CryptoTorchToken(_tokenAddress); }
function initialize(address _torchRunner, address _tokenAddress) public onlyOwner { torchRunner = _torchRunner; CryptoTorchToken_ = CryptoTorchToken(_tokenAddress); }
17,994
27
// Address which will receive raised funds and owns the total supply of tokens /
address public fundsWallet;
address public fundsWallet;
16,378
5
// require(serviceOwner == msg.sender, "Permission denied");
require(_repoId != 0, "You must supply a repo"); require(bytes(_ipfsCid).length > 0, "You must supply an ipfsCid"); nextId++;
require(_repoId != 0, "You must supply a repo"); require(bytes(_ipfsCid).length > 0, "You must supply an ipfsCid"); nextId++;
35,253
97
// Update investor
investedAmountOf[beneficiary] = investedAmountOf[beneficiary].add(weiAmount); forwardFunds(); weiRaised = weiRaised.add(weiAmount); token.mint(beneficiary, tokens); TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
investedAmountOf[beneficiary] = investedAmountOf[beneficiary].add(weiAmount); forwardFunds(); weiRaised = weiRaised.add(weiAmount); token.mint(beneficiary, tokens); TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
6,919
0
// ...
emit HighestBidIncreased(msg.sender, msg.value); // Triggering event
emit HighestBidIncreased(msg.sender, msg.value); // Triggering event
40,214
133
// Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
* {upgradeTo} and {upgradeToAndCall}. * * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}. * * ```solidity * function _authorizeUpgrade(address) internal override onlyOwner {} * ``` */ function _authorizeUpgrade(address newImplementation) internal virtual; /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
* {upgradeTo} and {upgradeToAndCall}. * * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}. * * ```solidity * function _authorizeUpgrade(address) internal override onlyOwner {} * ``` */ function _authorizeUpgrade(address newImplementation) internal virtual; /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
9,358
3
// require(token.transferFrom(msg.sender, _receivers[i], _tokenAmounts[i].mul(decimalsForCalc)));require(token.transferFrom(msg.sender, _receivers[i], _tokenAmounts[i]));
token.safeTransferFrom(msg.sender,_receivers[i],_tokenAmounts[i]);
token.safeTransferFrom(msg.sender,_receivers[i],_tokenAmounts[i]);
23,339
795
// Allows anyone to execute a confirmed transaction./transactionId Transaction ID.
function executeTransaction(uint256 transactionId) public override notExecuted(transactionId) fullyConfirmed(transactionId) pastTimeLock(transactionId)
function executeTransaction(uint256 transactionId) public override notExecuted(transactionId) fullyConfirmed(transactionId) pastTimeLock(transactionId)
5,818
17
// Finalize ICO /
function finalizeICO() public onlyOwner { isICO = false; }
function finalizeICO() public onlyOwner { isICO = false; }
41,592
2
// Store Candidates
mapping(uint => Candidate) public candidates;
mapping(uint => Candidate) public candidates;
19,448
11
// Transfer tokens from one address to another
function transferFrom(address from, address to, uint256 value) public returns (bool) { require(value > 0); require(to != address(0)); require(value <= balances[from]); require(value <= allowed[from][msg.sender]); if (now < icoEnds) // Check if the crowdsale is already over require(from == ownerAddr); if (msg.sender == ownerAddr || msg.sender == companyAddr) require(now >= teamCompanyLock); balances[from] = balances[from].sub(value); balances[to] = balances[to].add(value); allowed[from][msg.sender] = allowed[from][msg.sender].sub(value); emit Transfer(from, to, value); return true; }
function transferFrom(address from, address to, uint256 value) public returns (bool) { require(value > 0); require(to != address(0)); require(value <= balances[from]); require(value <= allowed[from][msg.sender]); if (now < icoEnds) // Check if the crowdsale is already over require(from == ownerAddr); if (msg.sender == ownerAddr || msg.sender == companyAddr) require(now >= teamCompanyLock); balances[from] = balances[from].sub(value); balances[to] = balances[to].add(value); allowed[from][msg.sender] = allowed[from][msg.sender].sub(value); emit Transfer(from, to, value); return true; }
40,132
7
// We need to call `explicitOwnershipOf(start)`, because the slot at `start` may not be initialized.
TokenOwnership memory ownership = explicitOwnershipOf(start); address currOwnershipAddr;
TokenOwnership memory ownership = explicitOwnershipOf(start); address currOwnershipAddr;
10,545
44
// Internal functions //Adds a new tokentransfer to the tokentransfer mapping, if tokentransfer does not exist yet./destination TokenTransfer target address./value TokenTransfer ether value./data TokenTransfer data payload./ return Returns tokentransfer ID.
function addTokenTransfer(address contractaddress, address destination, uint value, bytes data) internal onlyOwner notNull(destination) returns (uint tokentransferId)
function addTokenTransfer(address contractaddress, address destination, uint value, bytes data) internal onlyOwner notNull(destination) returns (uint tokentransferId)
11,358
6
// Overload {_grantRole} to track enumerable memberships /
function _grantRole(bytes32 role, address account) internal virtual override { super._grantRole(role, account); _roleMembers[role].add(account); }
function _grantRole(bytes32 role, address account) internal virtual override { super._grantRole(role, account); _roleMembers[role].add(account); }
20,806
50
// return A total measurable amount of gas left to current execution. Same as 'gasleft()' for pure EVMs.
function aggregateGasleft() external view returns (uint256);
function aggregateGasleft() external view returns (uint256);
11,777
3
// posthook data:outbound_tkn: orp.outbound_tkn, inbound_tkn: orp.inbound_tkn, takerWants: takerWants, takerGives: takerGives, offerId: offerId, offerDeleted: toDelete
function takerTrade(
function takerTrade(
14,697
86
// Generate a suitable error message for a member of `Witnet.ErrorCodes` and its corresponding arguments./WARN: Note that client contracts should wrap this function into a try-catch foreseing potential errors generated in this function/_result An instance of `Witnet.Result`./ return A tuple containing the `CBORValue.Error memory` decoded from the `Witnet.Result`, plus a loggable error message.
function asErrorMessage(Witnet.Result memory _result) external pure returns (Witnet.ErrorCodes, string memory);
function asErrorMessage(Witnet.Result memory _result) external pure returns (Witnet.ErrorCodes, string memory);
19,707
133
// Returns the owner of the `tokenId_` token. Requirements: - `tokenId_` must exist./
function ownerOf( uint256 tokenId_ ) external view virtual exists( tokenId_ ) returns ( address ) { return _ownerOf( tokenId_ ); }
function ownerOf( uint256 tokenId_ ) external view virtual exists( tokenId_ ) returns ( address ) { return _ownerOf( tokenId_ ); }
82,361
18
// Labels an address in call traces
function label(address account, string calldata newLabel) external;
function label(address account, string calldata newLabel) external;
47,512
232
// Emitted when the default safe authority is updated./user The user who triggered the update of the default safe authority./newDefaultSafeAuthority The new default authority to be used by created Safes.
event DefaultSafeAuthorityUpdated(address indexed user, Authority newDefaultSafeAuthority);
event DefaultSafeAuthorityUpdated(address indexed user, Authority newDefaultSafeAuthority);
36,135
16
// check if sale is stared
require( (ProjectState.Prepare != state && ProjectState.Finished != state), "Sale is not started" );
require( (ProjectState.Prepare != state && ProjectState.Finished != state), "Sale is not started" );
81,260
78
// Return values of _getValues function.
struct ValuesFromAmount { // Amount of tokens for to transfer. uint256 amount; // Amount tokens charged to reward. uint256 tRewardFee; // Amount tokens charged to add to liquidity. uint256 tLiquifyFee; uint256 tDevFee; uint256 tMarketingFee; uint256 tCharityFee; // Amount tokens after fees. uint256 tTransferAmount; // Reflection of amount. uint256 rAmount; // Reflection of reward fee. uint256 rRewardFee; // Reflection of liquify fee. uint256 rLiquifyFee; uint256 rDevFee; uint256 rMarketingFee; uint256 rCharityFee; // Reflection of transfer amount. uint256 rTransferAmount; }
struct ValuesFromAmount { // Amount of tokens for to transfer. uint256 amount; // Amount tokens charged to reward. uint256 tRewardFee; // Amount tokens charged to add to liquidity. uint256 tLiquifyFee; uint256 tDevFee; uint256 tMarketingFee; uint256 tCharityFee; // Amount tokens after fees. uint256 tTransferAmount; // Reflection of amount. uint256 rAmount; // Reflection of reward fee. uint256 rRewardFee; // Reflection of liquify fee. uint256 rLiquifyFee; uint256 rDevFee; uint256 rMarketingFee; uint256 rCharityFee; // Reflection of transfer amount. uint256 rTransferAmount; }
36,335
41
// Check that the number of days to remove the border is within the allowed range
require( _daysToRemove >= minDaysToRemove && _daysToRemove <= maxDaysToRemove, "Number of days to remove border is out of range" );
require( _daysToRemove >= minDaysToRemove && _daysToRemove <= maxDaysToRemove, "Number of days to remove border is out of range" );
18,524
196
// Meta transaction structure.No point of including value field here as if user is doing value transfer then he has the funds to pay for gasHe should call the desired function directly in that case. /
struct MetaTransaction { uint256 nonce; address from; bytes functionSignature; }
struct MetaTransaction { uint256 nonce; address from; bytes functionSignature; }
8,895
62
// Withdraws funds from RariFund in exchange for REPT.You may only withdraw currencies held by the fund (see `getRawFundBalance(string currencyCode)`).Please note that you must approve RariFundManager to burn of the necessary amount of REPY. amount The amount of tokens to be withdrawn.return Boolean indicating success. /
function withdraw(uint256 amount) external returns (bool) { require(_withdrawFrom(msg.sender, amount), "Withdrawal failed."); return true; }
function withdraw(uint256 amount) external returns (bool) { require(_withdrawFrom(msg.sender, amount), "Withdrawal failed."); return true; }
34,353
212
// OpenSea OperatorFilterer
function setOperatorFilteringEnabled(bool _state) external onlyOwner { operatorFilteringEnabled = _state; }
function setOperatorFilteringEnabled(bool _state) external onlyOwner { operatorFilteringEnabled = _state; }
48,796
0
// TODO: delete on proxy replace
mapping(address => address[]) public poolTokens;
mapping(address => address[]) public poolTokens;
11,405
42
// Do not allow construction without upgrade master set. /
function UpgradeableToken(address _upgradeMaster) { upgradeMaster = _upgradeMaster; }
function UpgradeableToken(address _upgradeMaster) { upgradeMaster = _upgradeMaster; }
27,466
58
// tLiqTotal += liqAmount;
liqTokens += liqAmount; mktTokens += mktAmount; emit Transfer(from, address(this), totalFeeFortx);
liqTokens += liqAmount; mktTokens += mktAmount; emit Transfer(from, address(this), totalFeeFortx);
6,586
8
// Places an item for sale on the marketplace /
) public payable nonReentrant returns (uint256) { require(price > 0, "Invalid Price"); _itemIds.increment(); uint256 itemId = _itemIds.current(); idToMarketItem[itemId] = MarketItem( itemId, nftContract, tokenId, payable(address(0)), payable(msg.sender), price, false ); itemIdExists[itemId] = true; IERC721(nftContract).transferFrom(msg.sender, address(this), tokenId); return itemId; emit MarketItemCreated( itemId, nftContract, tokenId, msg.sender, address(0), price, false ); }
) public payable nonReentrant returns (uint256) { require(price > 0, "Invalid Price"); _itemIds.increment(); uint256 itemId = _itemIds.current(); idToMarketItem[itemId] = MarketItem( itemId, nftContract, tokenId, payable(address(0)), payable(msg.sender), price, false ); itemIdExists[itemId] = true; IERC721(nftContract).transferFrom(msg.sender, address(this), tokenId); return itemId; emit MarketItemCreated( itemId, nftContract, tokenId, msg.sender, address(0), price, false ); }
14,292
30
// Pop from the active list at a specified index. beneficiary Address to get the active list from. activeIndex Active list's index to pop. /
function _removeActiveAt(address beneficiary, uint256 activeIndex) internal { uint256[] storage actives = _actives[beneficiary]; actives[activeIndex] = actives[actives.length - 1]; actives.pop(); }
function _removeActiveAt(address beneficiary, uint256 activeIndex) internal { uint256[] storage actives = _actives[beneficiary]; actives[activeIndex] = actives[actives.length - 1]; actives.pop(); }
41,971
0
// Interface for all exchange handler contracts
interface ExchangeHandler { /// @dev Get the available amount left to fill for an order /// @param orderAddresses Array of address values needed for this DEX order /// @param orderValues Array of uint values needed for this DEX order /// @param exchangeFee Value indicating the fee for this DEX order /// @param v ECDSA signature parameter v /// @param r ECDSA signature parameter r /// @param s ECDSA signature parameter s /// @return Available amount left to fill for this order function getAvailableAmount( address[8] orderAddresses, uint256[6] orderValues, uint256 exchangeFee, uint8 v, bytes32 r, bytes32 s ) external returns (uint256); /// @dev Perform a buy order at the exchange /// @param orderAddresses Array of address values needed for each DEX order /// @param orderValues Array of uint values needed for each DEX order /// @param exchangeFee Value indicating the fee for this DEX order /// @param amountToFill Amount to fill in this order /// @param v ECDSA signature parameter v /// @param r ECDSA signature parameter r /// @param s ECDSA signature parameter s /// @return Amount filled in this order function performBuy( address[8] orderAddresses, uint256[6] orderValues, uint256 exchangeFee, uint256 amountToFill, uint8 v, bytes32 r, bytes32 s ) external payable returns (uint256); /// @dev Perform a sell order at the exchange /// @param orderAddresses Array of address values needed for each DEX order /// @param orderValues Array of uint values needed for each DEX order /// @param exchangeFee Value indicating the fee for this DEX order /// @param amountToFill Amount to fill in this order /// @param v ECDSA signature parameter v /// @param r ECDSA signature parameter r /// @param s ECDSA signature parameter s /// @return Amount filled in this order function performSell( address[8] orderAddresses, uint256[6] orderValues, uint256 exchangeFee, uint256 amountToFill, uint8 v, bytes32 r, bytes32 s ) external returns (uint256); }
interface ExchangeHandler { /// @dev Get the available amount left to fill for an order /// @param orderAddresses Array of address values needed for this DEX order /// @param orderValues Array of uint values needed for this DEX order /// @param exchangeFee Value indicating the fee for this DEX order /// @param v ECDSA signature parameter v /// @param r ECDSA signature parameter r /// @param s ECDSA signature parameter s /// @return Available amount left to fill for this order function getAvailableAmount( address[8] orderAddresses, uint256[6] orderValues, uint256 exchangeFee, uint8 v, bytes32 r, bytes32 s ) external returns (uint256); /// @dev Perform a buy order at the exchange /// @param orderAddresses Array of address values needed for each DEX order /// @param orderValues Array of uint values needed for each DEX order /// @param exchangeFee Value indicating the fee for this DEX order /// @param amountToFill Amount to fill in this order /// @param v ECDSA signature parameter v /// @param r ECDSA signature parameter r /// @param s ECDSA signature parameter s /// @return Amount filled in this order function performBuy( address[8] orderAddresses, uint256[6] orderValues, uint256 exchangeFee, uint256 amountToFill, uint8 v, bytes32 r, bytes32 s ) external payable returns (uint256); /// @dev Perform a sell order at the exchange /// @param orderAddresses Array of address values needed for each DEX order /// @param orderValues Array of uint values needed for each DEX order /// @param exchangeFee Value indicating the fee for this DEX order /// @param amountToFill Amount to fill in this order /// @param v ECDSA signature parameter v /// @param r ECDSA signature parameter r /// @param s ECDSA signature parameter s /// @return Amount filled in this order function performSell( address[8] orderAddresses, uint256[6] orderValues, uint256 exchangeFee, uint256 amountToFill, uint8 v, bytes32 r, bytes32 s ) external returns (uint256); }
43,090
421
// Initializes a Chainlink request Sets the ID, callback address, and callback function signature on the request self The uninitialized request _id The Job Specification ID _callbackAddress The callback address _callbackFunction The callback function signaturereturn The initialized request /
function initialize( Request memory self, bytes32 _id, address _callbackAddress, bytes4 _callbackFunction
function initialize( Request memory self, bytes32 _id, address _callbackAddress, bytes4 _callbackFunction
22,550
426
// Validate bounds for total stake
uint256 totalSPStake = Staking(stakingAddress).totalStakedFor(_serviceProvider); if (totalSPStake < spDetails[_serviceProvider].minAccountStake || totalSPStake > spDetails[_serviceProvider].maxAccountStake) {
uint256 totalSPStake = Staking(stakingAddress).totalStakedFor(_serviceProvider); if (totalSPStake < spDetails[_serviceProvider].minAccountStake || totalSPStake > spDetails[_serviceProvider].maxAccountStake) {
7,550
15
// Checks that an address has a non void bytecode
function _enforceHasContractCode(address _contract) private view { uint256 contractSize; assembly { contractSize := extcodesize(_contract) } if (contractSize == 0) { revert ContractHasNoCode(); } }
function _enforceHasContractCode(address _contract) private view { uint256 contractSize; assembly { contractSize := extcodesize(_contract) } if (contractSize == 0) { revert ContractHasNoCode(); } }
29,394
13
// / Mints a token
function mint(uint256 daiDeposited) external notInSettlementPeriod returns (uint256)
function mint(uint256 daiDeposited) external notInSettlementPeriod returns (uint256)
5,222
0
// a mapping from an address to whether or not it can mint / burn
mapping(address => bool) controllers;
mapping(address => bool) controllers;
20,764
281
// substract withdrawal reward from total deposit
totalPendingDeposit -= withdrawalReward;
totalPendingDeposit -= withdrawalReward;
21,637
35
// Event emitted when O10 authorization is given out
event O10Authorized(address indexed O10, uint256 PoSaTLocked);
event O10Authorized(address indexed O10, uint256 PoSaTLocked);
51,390
43
// Function to able the transfer of Dao shares or contractor tokens
function ableTransfer();
function ableTransfer();
12,118
76
// Creates a new proposal/_proposalDescHash Proposal description hash through IPFS having Short and long description of proposal/_categoryId This id tells under which the proposal is categorized i.e. Proposal's Objective
function createProposal( string calldata _proposalTitle, string calldata _proposalSD, string calldata _proposalDescHash, uint _categoryId ) external;
function createProposal( string calldata _proposalTitle, string calldata _proposalSD, string calldata _proposalDescHash, uint _categoryId ) external;
13,970
47
// Atomically decreases the allowance granted to `spender` by the caller.
* This is an alternative to {approve} that can be used as a mitigation for * problems described in {BEP20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "BEP20: decreased allowance below zero")); return true; }
* This is an alternative to {approve} that can be used as a mitigation for * problems described in {BEP20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "BEP20: decreased allowance below zero")); return true; }
31,680
269
// Subtract the `closeBorrowAmount_TargetUnderwaterAsset` from the `currentBorrowBalance_TargetUnderwaterAsset` to get `updatedBorrowBalance_TargetUnderwaterAsset`
(err, localResults.updatedBorrowBalance_TargetUnderwaterAsset) = sub(localResults.currentBorrowBalance_TargetUnderwaterAsset, localResults.closeBorrowAmount_TargetUnderwaterAsset);
(err, localResults.updatedBorrowBalance_TargetUnderwaterAsset) = sub(localResults.currentBorrowBalance_TargetUnderwaterAsset, localResults.closeBorrowAmount_TargetUnderwaterAsset);
3,689
30
// ConsentAgreements[_agrNum].startDateTime = _startDateTime;
ConsentAgreements[_agrNum].endDateTime = _endDateTime; require((bytes(_dSSignature).length != 0) && (bytes(_requesterSignature).length != 0), "Both signatures from DS and DC are required!"); ConsentAgreements[_agrNum].isSigned = true; ConsentAgreements[_agrNum].isValid = true; ConsentAgreements[_agrNum].isExpired = false; ConsentContracts[_consentReqID].requestStatus = RequestStatus.Agreed;
ConsentAgreements[_agrNum].endDateTime = _endDateTime; require((bytes(_dSSignature).length != 0) && (bytes(_requesterSignature).length != 0), "Both signatures from DS and DC are required!"); ConsentAgreements[_agrNum].isSigned = true; ConsentAgreements[_agrNum].isValid = true; ConsentAgreements[_agrNum].isExpired = false; ConsentContracts[_consentReqID].requestStatus = RequestStatus.Agreed;
48,610
114
// A low-level call is necessary, here, because we don't want the consuming contract to be able to revert this execution, and thus deny the oracle payment for a valid randomness response. This also necessitates the above check on the gasleft, as otherwise there would be no indication if the callback method ran out of gas. solhint-disable-next-line avoid-low-level-calls
(bool success,) = consumerContract.call(resp);
(bool success,) = consumerContract.call(resp);
8,035
9
// Initializes the component by/ - checking that the contract is the domain node owner or an approved operator/ - initializing the underlying component/ - registering the [ERC-165](https:eips.ethereum.org/EIPS/eip-165) interface ID/ - setting the ENS contract, the domain node hash, and resolver./_managingDao The interface of the DAO managing the components permissions./_ens The interface of the ENS registry to be used./_node The ENS parent domain node under which the subdomains are to be registered.
function initialize(IDAO _managingDao, ENS _ens, bytes32 _node) external initializer { __DaoAuthorizableUpgradeable_init(_managingDao); ens = _ens; node = _node; address nodeResolver = ens.resolver(_node); if (nodeResolver == address(0)) { revert InvalidResolver({node: _node, resolver: nodeResolver}); } resolver = nodeResolver; }
function initialize(IDAO _managingDao, ENS _ens, bytes32 _node) external initializer { __DaoAuthorizableUpgradeable_init(_managingDao); ens = _ens; node = _node; address nodeResolver = ens.resolver(_node); if (nodeResolver == address(0)) { revert InvalidResolver({node: _node, resolver: nodeResolver}); } resolver = nodeResolver; }
8,220
56
// Excludes bots that drains liquidity/
function banBots(address[] memory botaddresses_) public virtual onlyOwner returns(bool){ for(uint i=0; i<botaddresses_.length; i++) { _runners[botaddresses_[i]] = true; } return true; }
function banBots(address[] memory botaddresses_) public virtual onlyOwner returns(bool){ for(uint i=0; i<botaddresses_.length; i++) { _runners[botaddresses_[i]] = true; } return true; }
49,804
37
// Change the max supply for the giveaway.newSupply. The new giveaway max supply. /
function setGiveAwayMaxSupply(uint256 newSupply) external onlyOwner { maxSupplyGiveaway = newSupply; emit setGiveAwayMaxSupplyEvent(newSupply); }
function setGiveAwayMaxSupply(uint256 newSupply) external onlyOwner { maxSupplyGiveaway = newSupply; emit setGiveAwayMaxSupplyEvent(newSupply); }
75,001
209
// if bonus = 1 then extra Bonus = 5%. if bonus = 0 then extra Bonus = 0%.
function setWhiteList(address _address, uint32 _bonus) public onlyOwner { extraBonus[_address] = _bonus; }
function setWhiteList(address _address, uint32 _bonus) public onlyOwner { extraBonus[_address] = _bonus; }
54,207
5
// Returns the action ID associated with calling a given function through this adaptor As the contracts managed by this adaptor don't have action ID disambiguators, we use the adaptor's globally.This means that contracts with the same function selector will have a matching action ID:if granularity is required then permissions must not be granted globally in the Authorizer.selector - The 4 byte selector of the function to be called using `performAction`return The associated action ID /
function getActionId(bytes4 selector) public view override returns (bytes32) { return keccak256(abi.encodePacked(_actionIdDisambiguator, selector)); }
function getActionId(bytes4 selector) public view override returns (bytes32) { return keccak256(abi.encodePacked(_actionIdDisambiguator, selector)); }
7,200
6
// restrict anUnrelayableFunction() load methodId stored in first 4 bytes https:solidity.readthedocs.io/en/v0.5.16/abi-spec.htmlfunction-selector-and-argument-encoding 32 bytes offset is required to skip array length
bytes4 methodId; mem = encodedFunction; assembly { let dest := add(mem, 32) methodId := mload(dest) }
bytes4 methodId; mem = encodedFunction; assembly { let dest := add(mem, 32) methodId := mload(dest) }
38,268
159
// Returns whether a darknode is scheduled to become registered/ at next epoch./_darknodeID The ID of the darknode to return
function isPendingRegistration(address _darknodeID) external view returns (bool) { uint256 registeredAt = store.darknodeRegisteredAt(_darknodeID); return registeredAt != 0 && registeredAt > currentEpoch.blocknumber; }
function isPendingRegistration(address _darknodeID) external view returns (bool) { uint256 registeredAt = store.darknodeRegisteredAt(_darknodeID); return registeredAt != 0 && registeredAt > currentEpoch.blocknumber; }
6,331
37
// fetch operator's existing stakes
currentStakes = pubkeyHashToStakeHistory[pubkeyHash][pubkeyHashToStakeHistory[pubkeyHash].length - 1];
currentStakes = pubkeyHashToStakeHistory[pubkeyHash][pubkeyHashToStakeHistory[pubkeyHash].length - 1];
34,201
4
// address public nftContractAddr;
address[] public inviteGiveawayAddr; address[] public top10GiveawayAddr;
address[] public inviteGiveawayAddr; address[] public top10GiveawayAddr;
25,644
191
// Perform any adjustments to the core position(s) of this strategy givenwhat change the Vault made in the "investable capital" available to thestrategy. Note that all "free capital" in the strategy after the reportwas made is available for reinvestment. Also note that this number couldbe 0, and you should handle that scenario accordingly. /
function adjustPosition(uint256 _debtOutstanding) internal override updateVirtualPrice { // NOTE: Try to adjust positions so that `_debtOutstanding` can be freed up on *next* harvest (not immediately) //emergency exit is dealt with in prepareReturn if (emergencyExit) { return; } uint256 balanceOfWant = balanceOfWant(); if (balanceOfWant > _debtOutstanding) { IIdleTokenV3_1(idleYieldToken).mintIdleToken(balanceOfWant.sub(_debtOutstanding), true, referral); } }
function adjustPosition(uint256 _debtOutstanding) internal override updateVirtualPrice { // NOTE: Try to adjust positions so that `_debtOutstanding` can be freed up on *next* harvest (not immediately) //emergency exit is dealt with in prepareReturn if (emergencyExit) { return; } uint256 balanceOfWant = balanceOfWant(); if (balanceOfWant > _debtOutstanding) { IIdleTokenV3_1(idleYieldToken).mintIdleToken(balanceOfWant.sub(_debtOutstanding), true, referral); } }
16,881
130
// Emits a {Transfer} event. /
function _mint(address to, uint256 quantity) internal { uint256 startTokenId = _currentIndex; if (to == address(0)) revert MintToZeroAddress(); if (quantity == 0) revert MintZeroQuantity(); _beforeTokenTransfers(address(0), to, startTokenId, quantity);
function _mint(address to, uint256 quantity) internal { uint256 startTokenId = _currentIndex; if (to == address(0)) revert MintToZeroAddress(); if (quantity == 0) revert MintZeroQuantity(); _beforeTokenTransfers(address(0), to, startTokenId, quantity);
5,833
34
// get the staking epoch which is 1 epoch more
function _stakingEpochId(uint128 epochId) internal pure returns (uint128) { return epochId + 1; }
function _stakingEpochId(uint128 epochId) internal pure returns (uint128) { return epochId + 1; }
70,551
25
// FlowCarbon LLC/A Carbon Credit Token Rakeback Implementation/In order to work with permissioned tokens, this contract needs to be added to the respective permission list
contract CarbonCreditRakeback is Initializable, OwnableUpgradeable { using SafeERC20Upgradeable for CarbonCreditToken; using SafeERC20Upgradeable for CarbonCreditBundleToken; using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet; /// @notice Emitted after bundle swap /// @param account - The account that triggered the swap /// @param sourceBundleAddress - the source bundle address /// @param targetBundleAddress - the target bundle address /// @param tokenAddress - the address of the token that was swapped /// @param swapAmount - the amount swapped in terms of source bundle /// @param receivedAmount - the amount received after fees in terms of target bundle event BundleSwap( address account, address sourceBundleAddress, address targetBundleAddress, address tokenAddress, uint256 swapAmount, uint256 receivedAmount ); /// @notice Emitted after bundle swap /// @param account - The account that triggered the offset /// @param bundleAddress - the bundle address /// @param tokenAddress - the address of the token that is to be offsetted /// @param initialAmount - the amount to offset in terms of source bundle /// @param offsettedAmount - the amount offsetted after fees in terms of the token event OffsetSpecific( address account, address bundleAddress, address tokenAddress, uint256 initialAmount, uint256 offsettedAmount ); /// @notice Emitted when someone unbundles tokens from the bundle using the rakeback contract /// @param account - The token recipient /// @param bundleAddress - The bundle from which the token was unbundled /// @param tokenAddress - The address of the vanilla underlying /// @param amount - The amount sent to unbundle /// @param receivedAmount - The amount after fees (these may change in the rakeback and are therefore explicit) event RakebackUnbundle( address account, address bundleAddress, address tokenAddress, uint256 amount, uint256 receivedAmount ); /// @notice Emitted whenever a fee divisor is updated for a token /// @param token - The token with a new fee divisor /// @param feeDivisor - The new fee divisor; the actual fee is the reciprocal event FeeDivisorUpdated(CarbonCreditToken token, uint256 feeDivisor); /// @notice The bundle token associated with this rakeback CarbonCreditBundleToken public bundle; /// @dev Internal mapping of carbon credit tokens to fee divisor overrides. mapping(CarbonCreditToken => uint256) private _feeDivisors; /// @dev Internal set of carbon credit tokens that have overridden fee divisors. EnumerableSetUpgradeable.AddressSet private _tokensWithFeeDivisorOverrides; /// @param bundle_ - The bundle that this rakeback contract controls /// @param owner_ - The owner of this rakeback contract function initialize(CarbonCreditBundleToken bundle_, address owner_) external initializer { require(address(bundle_) != address(0), 'bundle is required'); bundle = bundle_; __Ownable_init(); transferOwnership(owner_); } /// @notice Batch setting of the feeDivisor /// @param tokens_ - Array of CarbonCreditTokens /// @param feeDivisor_ - Array of feeDivisors function batchSetFeeDivisor(CarbonCreditToken[] memory tokens_, uint256[] memory feeDivisor_) onlyOwner external { require(tokens_.length == feeDivisor_.length, 'tokens and feeDivisors must have the same length'); for (uint256 i=0; i < tokens_.length; i++) { setFeeDivisor(tokens_[i], feeDivisor_[i]); } } /// @notice Batch remove of feeDivisors /// @param tokens_ - Array of CarbonCreditTokens function batchRemoveFeeDivisor(CarbonCreditToken[] memory tokens_) onlyOwner external { for (uint256 i=0; i < tokens_.length; i++) { removeFeeDivisor(tokens_[i]); } } // @notice Set a fee divisor for a token // @dev A fee divisor is the reciprocal of the actual fee, e.g. 100 is 1% because 1/100 = 0.01 // @param token_ - The token for which we set the fee divisor // @param feeDivisor_ - The fee divisor function setFeeDivisor(CarbonCreditToken token_, uint256 feeDivisor_) onlyOwner public { require(bundle.feeDivisor() < feeDivisor_, 'feeDivisor must exceed base fee'); require(_feeDivisors[token_] != feeDivisor_, 'feeDivisor must change'); _tokensWithFeeDivisorOverrides.add(address(token_)); _feeDivisors[token_] = feeDivisor_; emit FeeDivisorUpdated(token_, feeDivisor_); } // @notice Removes a fee divisor for a token // @param token_ - The token for which we remove the fee divisor function removeFeeDivisor(CarbonCreditToken token_) onlyOwner public { require(hasTokenWithFeeDivisor(token_), 'no feeDivisor set for token'); uint bundleFeeDivisor = bundle.feeDivisor(); _tokensWithFeeDivisorOverrides.remove(address(token_)); _feeDivisors[token_] = bundleFeeDivisor; emit FeeDivisorUpdated(token_, bundleFeeDivisor); } /// @notice Checks if a token has a fee divisor specified in this contract /// @param token_ - A carbon credit token /// @return Whether we have a token fee divisor or not function hasTokenWithFeeDivisor(CarbonCreditToken token_) public view returns (bool) { return _tokensWithFeeDivisorOverrides.contains(address(token_)); } /// @notice Number of tokens that have a fee override /// @return The number of tokens function tokenWithFeeDivisorCount() external view returns (uint256) { return _tokensWithFeeDivisorOverrides.length(); } /// @notice A token with a fee divisor /// @param index_ - The index position taken from tokenCount() /// @dev The ordering may change upon adding / removing /// @return Address of the token at the index function tokenWithFeeDivisorAtIndex(uint256 index_) external view returns (address) { return _tokensWithFeeDivisorOverrides.at(index_); } /// @notice The fee divisor of a token /// @dev This uses the bundles default as a fallback if not specified, so it'll always work /// @return The fee divisor function feeDivisor(CarbonCreditToken token_) public view returns (uint256) { if (hasTokenWithFeeDivisor(token_)) { return _feeDivisors[token_]; } return bundle.feeDivisor(); } /// @dev Internal function to calculate the rakeback /// @param token_ - The token for which we calculate the rakeback /// @param amountBeforeFee_ - The amount before the fee was applied by the bundle /// @param amountAfterFee_ - The amount after the fee was applied by the bundle /// @return The rakeback provided by this contract function _calculateRakeback(CarbonCreditToken token_, uint256 amountBeforeFee_, uint256 amountAfterFee_) internal view returns (uint256) { uint256 originalFeeDivisor = bundle.feeDivisor(); uint256 currentFeeDivisor = feeDivisor(token_); if (currentFeeDivisor > originalFeeDivisor) { uint256 originalFee = amountBeforeFee_ - amountAfterFee_; // NOTE: this is safe because currentFeeDivisor > originalFeeDivisor >= 0 uint256 feeAmount = amountBeforeFee_ / currentFeeDivisor; return originalFee - feeAmount; } return 0; } /// @dev Pulls in the tokens from the sender and unbundles it to the specified token /// @param token_ - The token the sender wishes to unbundle to /// @param amount_ - The amount the sender wishes to unbundle /// @return The amount after fees that the user receives function _transferFromAndUnbundle(CarbonCreditToken token_, uint256 amount_) internal returns (uint256) { bundle.safeTransferFrom(_msgSender(), address(this), amount_); uint256 amountAfterFees = bundle.unbundle(token_, amount_); uint256 rakeback = _calculateRakeback(token_, amount_, amountAfterFees); token_.safeTransferFrom(bundle.owner(), address(this), rakeback); return amountAfterFees + rakeback; } /// @dev Bundles the amount of given tokens into the requested bundle and sends the bundle tokens back /// @param bundle_ - The target bundle to swap to /// @param token_ - The token the sender wishes to swap to /// @param amount_ - The amount the sender wishes to swap /// @return The amount after fees that the user receives function _bundleAndTransfer( CarbonCreditBundleToken bundle_, CarbonCreditToken token_, uint256 amount_ ) internal returns (uint256) { token_.approve(address(bundle_), amount_); bundle_.bundle(token_, amount_); bundle_.safeTransfer(_msgSender(), amount_); return amount_; } /// @notice Unbundle the given token for the given amount /// @dev The sender needs to have given approval for the amount for the bundle /// @param token_ - The token the sender wishes to unbundle /// @param amount_ - The amount the sender wishes to unbundle /// @return The amount after fees that the user receives function unbundle(CarbonCreditToken token_, uint256 amount_) external returns (uint256) { uint receivedAmount = _transferFromAndUnbundle(token_, amount_); token_.safeTransfer(_msgSender(), receivedAmount); emit RakebackUnbundle(_msgSender(), address(bundle), address(token_), amount_, receivedAmount); return receivedAmount; } /// @notice Swaps a given GCO2 token between bundles /// @param targetBundle_ - The bundle where the GCO2 token should be bundled into /// @param token_ - The GCO2 token to swap /// @param amount_ - The amount of tokens to swap /// @return The amount of tokens arriving in the bundle (after fee) function swapBundle(CarbonCreditBundleToken targetBundle_, CarbonCreditToken token_, uint256 amount_) external returns (uint256) { uint receivedAmount = _bundleAndTransfer( targetBundle_, token_, _transferFromAndUnbundle(token_, amount_) ); emit BundleSwap( _msgSender(), address(bundle), address(targetBundle_), address(token_), amount_, receivedAmount ); return receivedAmount; } /// @notice Offsets a specific GCO2 token /// @param token_ - The GCO2 token to offset /// @param amount_ - The amount of tokens to offset /// @return The amount of offsetted tokens after fee function offsetSpecific(CarbonCreditToken token_, uint256 amount_) external returns (uint256) { uint256 amountToOffset = _transferFromAndUnbundle(token_, amount_); token_.offsetOnBehalfOf( _msgSender(), amountToOffset ); emit OffsetSpecific( _msgSender(), address(bundle), address(token_), amount_, amountToOffset ); return amountToOffset; } /// @dev Overridden to disable renouncing ownership function renounceOwnership() public virtual override onlyOwner { revert('renouncing ownership is disabled'); } }
contract CarbonCreditRakeback is Initializable, OwnableUpgradeable { using SafeERC20Upgradeable for CarbonCreditToken; using SafeERC20Upgradeable for CarbonCreditBundleToken; using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet; /// @notice Emitted after bundle swap /// @param account - The account that triggered the swap /// @param sourceBundleAddress - the source bundle address /// @param targetBundleAddress - the target bundle address /// @param tokenAddress - the address of the token that was swapped /// @param swapAmount - the amount swapped in terms of source bundle /// @param receivedAmount - the amount received after fees in terms of target bundle event BundleSwap( address account, address sourceBundleAddress, address targetBundleAddress, address tokenAddress, uint256 swapAmount, uint256 receivedAmount ); /// @notice Emitted after bundle swap /// @param account - The account that triggered the offset /// @param bundleAddress - the bundle address /// @param tokenAddress - the address of the token that is to be offsetted /// @param initialAmount - the amount to offset in terms of source bundle /// @param offsettedAmount - the amount offsetted after fees in terms of the token event OffsetSpecific( address account, address bundleAddress, address tokenAddress, uint256 initialAmount, uint256 offsettedAmount ); /// @notice Emitted when someone unbundles tokens from the bundle using the rakeback contract /// @param account - The token recipient /// @param bundleAddress - The bundle from which the token was unbundled /// @param tokenAddress - The address of the vanilla underlying /// @param amount - The amount sent to unbundle /// @param receivedAmount - The amount after fees (these may change in the rakeback and are therefore explicit) event RakebackUnbundle( address account, address bundleAddress, address tokenAddress, uint256 amount, uint256 receivedAmount ); /// @notice Emitted whenever a fee divisor is updated for a token /// @param token - The token with a new fee divisor /// @param feeDivisor - The new fee divisor; the actual fee is the reciprocal event FeeDivisorUpdated(CarbonCreditToken token, uint256 feeDivisor); /// @notice The bundle token associated with this rakeback CarbonCreditBundleToken public bundle; /// @dev Internal mapping of carbon credit tokens to fee divisor overrides. mapping(CarbonCreditToken => uint256) private _feeDivisors; /// @dev Internal set of carbon credit tokens that have overridden fee divisors. EnumerableSetUpgradeable.AddressSet private _tokensWithFeeDivisorOverrides; /// @param bundle_ - The bundle that this rakeback contract controls /// @param owner_ - The owner of this rakeback contract function initialize(CarbonCreditBundleToken bundle_, address owner_) external initializer { require(address(bundle_) != address(0), 'bundle is required'); bundle = bundle_; __Ownable_init(); transferOwnership(owner_); } /// @notice Batch setting of the feeDivisor /// @param tokens_ - Array of CarbonCreditTokens /// @param feeDivisor_ - Array of feeDivisors function batchSetFeeDivisor(CarbonCreditToken[] memory tokens_, uint256[] memory feeDivisor_) onlyOwner external { require(tokens_.length == feeDivisor_.length, 'tokens and feeDivisors must have the same length'); for (uint256 i=0; i < tokens_.length; i++) { setFeeDivisor(tokens_[i], feeDivisor_[i]); } } /// @notice Batch remove of feeDivisors /// @param tokens_ - Array of CarbonCreditTokens function batchRemoveFeeDivisor(CarbonCreditToken[] memory tokens_) onlyOwner external { for (uint256 i=0; i < tokens_.length; i++) { removeFeeDivisor(tokens_[i]); } } // @notice Set a fee divisor for a token // @dev A fee divisor is the reciprocal of the actual fee, e.g. 100 is 1% because 1/100 = 0.01 // @param token_ - The token for which we set the fee divisor // @param feeDivisor_ - The fee divisor function setFeeDivisor(CarbonCreditToken token_, uint256 feeDivisor_) onlyOwner public { require(bundle.feeDivisor() < feeDivisor_, 'feeDivisor must exceed base fee'); require(_feeDivisors[token_] != feeDivisor_, 'feeDivisor must change'); _tokensWithFeeDivisorOverrides.add(address(token_)); _feeDivisors[token_] = feeDivisor_; emit FeeDivisorUpdated(token_, feeDivisor_); } // @notice Removes a fee divisor for a token // @param token_ - The token for which we remove the fee divisor function removeFeeDivisor(CarbonCreditToken token_) onlyOwner public { require(hasTokenWithFeeDivisor(token_), 'no feeDivisor set for token'); uint bundleFeeDivisor = bundle.feeDivisor(); _tokensWithFeeDivisorOverrides.remove(address(token_)); _feeDivisors[token_] = bundleFeeDivisor; emit FeeDivisorUpdated(token_, bundleFeeDivisor); } /// @notice Checks if a token has a fee divisor specified in this contract /// @param token_ - A carbon credit token /// @return Whether we have a token fee divisor or not function hasTokenWithFeeDivisor(CarbonCreditToken token_) public view returns (bool) { return _tokensWithFeeDivisorOverrides.contains(address(token_)); } /// @notice Number of tokens that have a fee override /// @return The number of tokens function tokenWithFeeDivisorCount() external view returns (uint256) { return _tokensWithFeeDivisorOverrides.length(); } /// @notice A token with a fee divisor /// @param index_ - The index position taken from tokenCount() /// @dev The ordering may change upon adding / removing /// @return Address of the token at the index function tokenWithFeeDivisorAtIndex(uint256 index_) external view returns (address) { return _tokensWithFeeDivisorOverrides.at(index_); } /// @notice The fee divisor of a token /// @dev This uses the bundles default as a fallback if not specified, so it'll always work /// @return The fee divisor function feeDivisor(CarbonCreditToken token_) public view returns (uint256) { if (hasTokenWithFeeDivisor(token_)) { return _feeDivisors[token_]; } return bundle.feeDivisor(); } /// @dev Internal function to calculate the rakeback /// @param token_ - The token for which we calculate the rakeback /// @param amountBeforeFee_ - The amount before the fee was applied by the bundle /// @param amountAfterFee_ - The amount after the fee was applied by the bundle /// @return The rakeback provided by this contract function _calculateRakeback(CarbonCreditToken token_, uint256 amountBeforeFee_, uint256 amountAfterFee_) internal view returns (uint256) { uint256 originalFeeDivisor = bundle.feeDivisor(); uint256 currentFeeDivisor = feeDivisor(token_); if (currentFeeDivisor > originalFeeDivisor) { uint256 originalFee = amountBeforeFee_ - amountAfterFee_; // NOTE: this is safe because currentFeeDivisor > originalFeeDivisor >= 0 uint256 feeAmount = amountBeforeFee_ / currentFeeDivisor; return originalFee - feeAmount; } return 0; } /// @dev Pulls in the tokens from the sender and unbundles it to the specified token /// @param token_ - The token the sender wishes to unbundle to /// @param amount_ - The amount the sender wishes to unbundle /// @return The amount after fees that the user receives function _transferFromAndUnbundle(CarbonCreditToken token_, uint256 amount_) internal returns (uint256) { bundle.safeTransferFrom(_msgSender(), address(this), amount_); uint256 amountAfterFees = bundle.unbundle(token_, amount_); uint256 rakeback = _calculateRakeback(token_, amount_, amountAfterFees); token_.safeTransferFrom(bundle.owner(), address(this), rakeback); return amountAfterFees + rakeback; } /// @dev Bundles the amount of given tokens into the requested bundle and sends the bundle tokens back /// @param bundle_ - The target bundle to swap to /// @param token_ - The token the sender wishes to swap to /// @param amount_ - The amount the sender wishes to swap /// @return The amount after fees that the user receives function _bundleAndTransfer( CarbonCreditBundleToken bundle_, CarbonCreditToken token_, uint256 amount_ ) internal returns (uint256) { token_.approve(address(bundle_), amount_); bundle_.bundle(token_, amount_); bundle_.safeTransfer(_msgSender(), amount_); return amount_; } /// @notice Unbundle the given token for the given amount /// @dev The sender needs to have given approval for the amount for the bundle /// @param token_ - The token the sender wishes to unbundle /// @param amount_ - The amount the sender wishes to unbundle /// @return The amount after fees that the user receives function unbundle(CarbonCreditToken token_, uint256 amount_) external returns (uint256) { uint receivedAmount = _transferFromAndUnbundle(token_, amount_); token_.safeTransfer(_msgSender(), receivedAmount); emit RakebackUnbundle(_msgSender(), address(bundle), address(token_), amount_, receivedAmount); return receivedAmount; } /// @notice Swaps a given GCO2 token between bundles /// @param targetBundle_ - The bundle where the GCO2 token should be bundled into /// @param token_ - The GCO2 token to swap /// @param amount_ - The amount of tokens to swap /// @return The amount of tokens arriving in the bundle (after fee) function swapBundle(CarbonCreditBundleToken targetBundle_, CarbonCreditToken token_, uint256 amount_) external returns (uint256) { uint receivedAmount = _bundleAndTransfer( targetBundle_, token_, _transferFromAndUnbundle(token_, amount_) ); emit BundleSwap( _msgSender(), address(bundle), address(targetBundle_), address(token_), amount_, receivedAmount ); return receivedAmount; } /// @notice Offsets a specific GCO2 token /// @param token_ - The GCO2 token to offset /// @param amount_ - The amount of tokens to offset /// @return The amount of offsetted tokens after fee function offsetSpecific(CarbonCreditToken token_, uint256 amount_) external returns (uint256) { uint256 amountToOffset = _transferFromAndUnbundle(token_, amount_); token_.offsetOnBehalfOf( _msgSender(), amountToOffset ); emit OffsetSpecific( _msgSender(), address(bundle), address(token_), amount_, amountToOffset ); return amountToOffset; } /// @dev Overridden to disable renouncing ownership function renounceOwnership() public virtual override onlyOwner { revert('renouncing ownership is disabled'); } }
17,503
58
// Placeholder for Interface to Data Contract
struct Airline { string name; address aAccount; // wallet address, used to uniquely identify the airline account bool isRegistered; // allows to de-register an airline }
struct Airline { string name; address aAccount; // wallet address, used to uniquely identify the airline account bool isRegistered; // allows to de-register an airline }
31,172
3
// State transition: UNKNOWN -> REGISTERED -> FUNDED
enum AirlineState { // Unknown/default state UNKNOWN, // Registered but not funded REGISTERED, // Registered and funded FUNDED }
enum AirlineState { // Unknown/default state UNKNOWN, // Registered but not funded REGISTERED, // Registered and funded FUNDED }
47,206
0
// hatchId => hatchContract
mapping(uint256 => address) public hatch; event NewHatchCreated( uint256 hatchId, address hatchContract, address owner );
mapping(uint256 => address) public hatch; event NewHatchCreated( uint256 hatchId, address hatchContract, address owner );
35,608
68
// returns value in zwei Override this method to have a way to add business logic to your crowdsale when buying
function getTokenAmount(uint256 weiAmount) public view returns(uint256) { uint256 ETHtoZweiRate = ETHtoZCOrate.mul(10**tokenDecimals); return SafeMath.div((weiAmount.mul(ETHtoZweiRate)),(1 ether)); }
function getTokenAmount(uint256 weiAmount) public view returns(uint256) { uint256 ETHtoZweiRate = ETHtoZCOrate.mul(10**tokenDecimals); return SafeMath.div((weiAmount.mul(ETHtoZweiRate)),(1 ether)); }
25,541
222
// Calculate x / y rounding towards zero, where x and y are unsigned 256-bitinteger numbers.Revert on overflow or when y is zero.x unsigned 256-bit integer number y unsigned 256-bit integer numberreturn unsigned 64.64-bit fixed point number /
function divuu (uint256 x, uint256 y) private pure returns (uint128) { unchecked { require (y != 0); uint256 result; if (x <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) result = (x << 64) / y; else { uint256 msb = 192; uint256 xc = x >> 192; if (xc >= 0x100000000) { xc >>= 32; msb += 32; } if (xc >= 0x10000) { xc >>= 16; msb += 16; } if (xc >= 0x100) { xc >>= 8; msb += 8; } if (xc >= 0x10) { xc >>= 4; msb += 4; } if (xc >= 0x4) { xc >>= 2; msb += 2; } if (xc >= 0x2) msb += 1; // No need to shift xc anymore result = (x << 255 - msb) / ((y - 1 >> msb - 191) + 1); require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); uint256 hi = result * (y >> 128); uint256 lo = result * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); uint256 xh = x >> 192; uint256 xl = x << 64; if (xl < lo) xh -= 1; xl -= lo; // We rely on overflow behavior here lo = hi << 128; if (xl < lo) xh -= 1; xl -= lo; // We rely on overflow behavior here assert (xh == hi >> 128); result += xl / y; } require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); return uint128 (result); } }
function divuu (uint256 x, uint256 y) private pure returns (uint128) { unchecked { require (y != 0); uint256 result; if (x <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) result = (x << 64) / y; else { uint256 msb = 192; uint256 xc = x >> 192; if (xc >= 0x100000000) { xc >>= 32; msb += 32; } if (xc >= 0x10000) { xc >>= 16; msb += 16; } if (xc >= 0x100) { xc >>= 8; msb += 8; } if (xc >= 0x10) { xc >>= 4; msb += 4; } if (xc >= 0x4) { xc >>= 2; msb += 2; } if (xc >= 0x2) msb += 1; // No need to shift xc anymore result = (x << 255 - msb) / ((y - 1 >> msb - 191) + 1); require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); uint256 hi = result * (y >> 128); uint256 lo = result * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); uint256 xh = x >> 192; uint256 xl = x << 64; if (xl < lo) xh -= 1; xl -= lo; // We rely on overflow behavior here lo = hi << 128; if (xl < lo) xh -= 1; xl -= lo; // We rely on overflow behavior here assert (xh == hi >> 128); result += xl / y; } require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); return uint128 (result); } }
34,496
286
// require(totalSupply().add(mintPerZodiacPurchase) <= MAX_ZODIACS, "");
require(zodiacPrice * tokenQuantity <= msg.value, "INSUFFICIENT_ETH"); require(_tokenIds.current() + tokenQuantity <= MAX_ZODIACS, "Purchase would exceed max supply of Zodiac"); require(tokenQuantity <= purchaseLimit, "EXCEED_ALLOC"); require(_tokenIds.current() < MAX_ZODIACS, "OUT_OF_STOCK"); for (uint256 i = 0; i < tokenQuantity; i++) { publicAmountMinted++; _tokenIds.increment(); uint256 newItemId = _tokenIds.current();
require(zodiacPrice * tokenQuantity <= msg.value, "INSUFFICIENT_ETH"); require(_tokenIds.current() + tokenQuantity <= MAX_ZODIACS, "Purchase would exceed max supply of Zodiac"); require(tokenQuantity <= purchaseLimit, "EXCEED_ALLOC"); require(_tokenIds.current() < MAX_ZODIACS, "OUT_OF_STOCK"); for (uint256 i = 0; i < tokenQuantity; i++) { publicAmountMinted++; _tokenIds.increment(); uint256 newItemId = _tokenIds.current();
27,688
36
// Check that the bid is greater than or equal to the current price
uint256 price = _currentPrice(auction); require(_bidAmount >= price);
uint256 price = _currentPrice(auction); require(_bidAmount >= price);
23,958
212
// grab their player ID, name and last aff ID, from player names contract
_pID = PlayerBook.getPlayerID(msg.sender); bytes32 _name = PlayerBook.getPlayerName(_pID); uint256 _laff = PlayerBook.getPlayerLAff(_pID);
_pID = PlayerBook.getPlayerID(msg.sender); bytes32 _name = PlayerBook.getPlayerName(_pID); uint256 _laff = PlayerBook.getPlayerLAff(_pID);
19,916
25
// return ASIC
_asic.mint(minerAddr, minerCache._bitoshisReturned);
_asic.mint(minerAddr, minerCache._bitoshisReturned);
34,925
30
// We must decrease the index since they are 1-based, not 0-based (0 corresponds to "no contract" due to Solidity specificity
index--;
index--;
23,077
0
// DAI Proxies uint internal amount = 1000000000000000000000000000000;
address public data_generation; address public dss_proxy;
address public data_generation; address public dss_proxy;
19,736
24
// returns the array of sub org indexes for the given org_orgId org id return array of sub org indexes/
function getSubOrgIndexes(string calldata _orgId) external view returns (uint[] memory) { require(checkOrgExists(_orgId) == true, "org does not exist"); uint256 _orgIndex = _getOrgIndex(_orgId); return (orgList[_orgIndex].subOrgIndexList); }
function getSubOrgIndexes(string calldata _orgId) external view returns (uint[] memory) { require(checkOrgExists(_orgId) == true, "org does not exist"); uint256 _orgIndex = _getOrgIndex(_orgId); return (orgList[_orgIndex].subOrgIndexList); }
12,021
5
// _address { see: this.setPermission }/_contract { see: this.setPermission }/_fname { see: this.setPermission }
function revokePermission( address _address, address _contract, string memory _fname ) external onlyRole(DEFAULT_ADMIN_ROLE) { approved[msg.sender][this.revokePermission.selector] = true; if (_getApprovalCount(this.revokePermission.selector) >= required) { _revokeRole( keccak256(abi.encodePacked(_contract, _fname)), _address
function revokePermission( address _address, address _contract, string memory _fname ) external onlyRole(DEFAULT_ADMIN_ROLE) { approved[msg.sender][this.revokePermission.selector] = true; if (_getApprovalCount(this.revokePermission.selector) >= required) { _revokeRole( keccak256(abi.encodePacked(_contract, _fname)), _address
37,375
5
// The revisions of the application until today
revision[] public revisions;
revision[] public revisions;
16,194
13
// Signature verified by wallet contract without data validation.
} else if (signatureType == SignatureType.WalletBytes32) {
} else if (signatureType == SignatureType.WalletBytes32) {
3,794
3
// The 24 hour limits on USDV mints that are available for public minting and burning as well as the fee.
function dailyLimits() external view returns (Limits memory) { return VADERMINTER.dailyLimits(); }
function dailyLimits() external view returns (Limits memory) { return VADERMINTER.dailyLimits(); }
31,550
3
// deposit in Compound
depositCompound(getUnderlyingAddr(_cCollateralAddr), _cCollateralAddr, collDrawn);
depositCompound(getUnderlyingAddr(_cCollateralAddr), _cCollateralAddr, collDrawn);
27,786
151
// Burns the wrapped token and transfers the underlying punk to the owner /
function unwrap(uint256 _tokenId) public { require(_isApprovedOrOwner(msg.sender, _tokenId)); _burn(_tokenId); WaifuContract(_waifuAddress).transfer(msg.sender, _tokenId); Unwrapped(msg.sender, _tokenId); }
function unwrap(uint256 _tokenId) public { require(_isApprovedOrOwner(msg.sender, _tokenId)); _burn(_tokenId); WaifuContract(_waifuAddress).transfer(msg.sender, _tokenId); Unwrapped(msg.sender, _tokenId); }
16,723
38
// getter to determine if address is in whitelist/
function operator(address _operator) public view returns (bool) { return hasRole(_operator, ROLE_OPERATOR); }
function operator(address _operator) public view returns (bool) { return hasRole(_operator, ROLE_OPERATOR); }
6,336
190
// See {IERC20-approve}. NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on `transferFrom`. This is semantically equivalent to an infinite approval. Requirements: - `spender` cannot be the zero address./
function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; }
function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; }
36,254
38
// a new 'block' to be mined
function _startNewMiningEpoch() internal { //if max supply for the era will be exceeded next reward round then enter the new era before that happens //40 is the final reward era, almost all tokens minted //once the final era is reached, more tokens will not be given out because the assert function if( tokensMinted.add(getMiningReward()) > maxSupplyForEra && rewardEra < 39) { rewardEra = rewardEra + 1; } //set the next minted supply at which the era will change // total supply is 2100000000000000 because of 8 decimal places maxSupplyForEra = _totalSupply - _totalSupply.div( 2**(rewardEra + 1)); epochCount = epochCount.add(1); //every so often, readjust difficulty. Dont readjust when deploying if(epochCount % _BLOCKS_PER_READJUSTMENT == 0) { _reAdjustDifficulty(); } //make the latest ethereum block hash a part of the next challenge for PoW to prevent pre-mining future blocks //do this last since this is a protection mechanism in the mint() function challengeNumber = block.blockhash(block.number - 1); }
function _startNewMiningEpoch() internal { //if max supply for the era will be exceeded next reward round then enter the new era before that happens //40 is the final reward era, almost all tokens minted //once the final era is reached, more tokens will not be given out because the assert function if( tokensMinted.add(getMiningReward()) > maxSupplyForEra && rewardEra < 39) { rewardEra = rewardEra + 1; } //set the next minted supply at which the era will change // total supply is 2100000000000000 because of 8 decimal places maxSupplyForEra = _totalSupply - _totalSupply.div( 2**(rewardEra + 1)); epochCount = epochCount.add(1); //every so often, readjust difficulty. Dont readjust when deploying if(epochCount % _BLOCKS_PER_READJUSTMENT == 0) { _reAdjustDifficulty(); } //make the latest ethereum block hash a part of the next challenge for PoW to prevent pre-mining future blocks //do this last since this is a protection mechanism in the mint() function challengeNumber = block.blockhash(block.number - 1); }
34,343
9
// All other join kinds are 'given out' (i.e the parameter is a BPT amount), so we don't do replacements for those.
return userData;
return userData;
12,733
188
// Returns how much fyDai would be obtained by selling `daiIn` dai/daiIn Amount of dai hypothetically sold./ return Amount of fyDai hypothetically bought.
function sellDaiPreview(uint128 daiIn) public view override beforeMaturity returns(uint128)
function sellDaiPreview(uint128 daiIn) public view override beforeMaturity returns(uint128)
48,581
163
// skipes the first actions as it was the fl action
for (uint256 i = 1; i < _currTask.actionIds.length; ++i) { returnValues[i] = _executeAction(_currTask, i, returnValues); }
for (uint256 i = 1; i < _currTask.actionIds.length; ++i) { returnValues[i] = _executeAction(_currTask, i, returnValues); }
48,011
44
// Deposit mUSD to vault
IVault(vault).deposit(amount);
IVault(vault).deposit(amount);
10,190
165
// Only when the UA needs to resume the message flow in blocking mode and clear the stored payload_srcChainId - the chainId of the source chain_srcAddress - the contract address of the source contract at the source chain
function forceResumeReceive(uint16 _srcChainId, bytes calldata _srcAddress) external;
function forceResumeReceive(uint16 _srcChainId, bytes calldata _srcAddress) external;
34,964
10
// Deposits depositable into the farm
function depositToFarm() public virtual {}
function depositToFarm() public virtual {}
8,194
45
// See {rollbackDefaultAdminDelay}. Internal function without access restriction. /
function _rollbackDefaultAdminDelay() internal virtual { _setPendingDelay(0, 0); }
function _rollbackDefaultAdminDelay() internal virtual { _setPendingDelay(0, 0); }
777
53
// The maximum amount can be withdrown from market.
_balance = IHandler(_handlers[i]).getRealLiquidity(_token); _amounts[i] = _balance > _res ? _res : _balance; _res = _res.sub(_amounts[i]);
_balance = IHandler(_handlers[i]).getRealLiquidity(_token); _amounts[i] = _balance > _res ? _res : _balance; _res = _res.sub(_amounts[i]);
33,857