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
816
// This function allows any participant to retrievethe receipt for a given proposal and voter. _proposalId Proposal id. _voter Voter address.return Voter receipt. /
function getReceipt(uint128 _proposalId, address _voter) external view returns (GovernanceDefs.Receipt memory) { LibDiamondStorageGovernance.DiamondStorageGovernance storage dsGovernance = LibDiamondStorageGovernance.diamondStorageGovernance(); return dsGovernance.proposals[_proposalId].receipts[_voter]; }
function getReceipt(uint128 _proposalId, address _voter) external view returns (GovernanceDefs.Receipt memory) { LibDiamondStorageGovernance.DiamondStorageGovernance storage dsGovernance = LibDiamondStorageGovernance.diamondStorageGovernance(); return dsGovernance.proposals[_proposalId].receipts[_voter]; }
35,134
5
// Maximum number of level of apps can be composed together NOTE:- TODO Composite app feature is currently disabled. Hence app cannotwill not be able to call other app. / solhint-disable-next-line var-name-mixedcase
uint immutable public MAX_APP_LEVEL = 1;
uint immutable public MAX_APP_LEVEL = 1;
10,425
27
// ------------------------------------------------------------------------ Transferred approved amount from other's account ------------------------------------------------------------------------
function transferFrom(address _from, address _to, uint _value) unfreezed(_to) unfreezed(_from) unfreezed(msg.sender) noEmergencyFreeze() public returns (bool success)
function transferFrom(address _from, address _to, uint _value) unfreezed(_to) unfreezed(_from) unfreezed(msg.sender) noEmergencyFreeze() public returns (bool success)
6,892
42
// Returns the erc token owner. /
function getOwner() external view virtual override returns (address) { return owner(); }
function getOwner() external view virtual override returns (address) { return owner(); }
10,859
89
// keccak256 hash of "cube.counter" prettier-ignore
bytes32 public constant CUBE_COUNTER_KEY = 0xf9543f11459ccccd21306c8881aaab675ff49d988c1162fd1dd9bbcdbe4446be;
bytes32 public constant CUBE_COUNTER_KEY = 0xf9543f11459ccccd21306c8881aaab675ff49d988c1162fd1dd9bbcdbe4446be;
8,299
14
// Check if swap to native ETH was requested
if (tokenOut == UniversalToken.ETH_ADDRESS) {
if (tokenOut == UniversalToken.ETH_ADDRESS) {
16,578
78
// Atomically increases the allowance granted to `spender` by the caller
* @dev This is an alternative to {approve} that can be used as a mitigation for * problems described in {BEP20-approve}. * @param spender The address of the account which may transfer tokens * @param addedValue The additional number of tokens to allow which may be spent * @return Whether or not the approval succeeded */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; }
* @dev This is an alternative to {approve} that can be used as a mitigation for * problems described in {BEP20-approve}. * @param spender The address of the account which may transfer tokens * @param addedValue The additional number of tokens to allow which may be spent * @return Whether or not the approval succeeded */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; }
17,071
33
// Check dividends owned by the caller
function myDividends(bool _includeReferralBonus) public view returns(uint256) { address _customerAddress = msg.sender; return _includeReferralBonus ? dividendsOf(_customerAddress) + referralBalance_[_customerAddress] : dividendsOf(_customerAddress) ; }
function myDividends(bool _includeReferralBonus) public view returns(uint256) { address _customerAddress = msg.sender; return _includeReferralBonus ? dividendsOf(_customerAddress) + referralBalance_[_customerAddress] : dividendsOf(_customerAddress) ; }
29,894
96
// A crowdsaled token. An ERC-20 token designed specifically for crowdsales with investor protection and further development path. - The token transfer() is disabled until the crowdsale is over- The token contract gives an opt-in upgrade path to a new contract- The same token can be part of several crowdsales through approve() mechanism- The token can be capped (supply set in the constructor) or uncapped (crowdsale contract can mint new tokens)/
contract CrowdsaleTokenExt is ReleasableToken, MintableTokenExt, UpgradeableToken { /** Name and symbol were updated. */ event UpdatedTokenInformation(string newName, string newSymbol); event ClaimedTokens(address indexed _token, address indexed _controller, uint _amount); string public name; string public symbol; uint public decimals; /* Minimum ammount of tokens every buyer can buy. */ uint public minCap; /** * Construct the token. * * This token must be created through a team multisig wallet, so that it is owned by that wallet. * * @param _name Token name * @param _symbol Token symbol - should be all caps * @param _initialSupply How many tokens we start with * @param _decimals Number of decimal places * @param _mintable Are new tokens created over the crowdsale or do we distribute only the initial supply? Note that when the token becomes transferable the minting always ends. */ function CrowdsaleTokenExt(string _name, string _symbol, uint _initialSupply, uint _decimals, bool _mintable, uint _globalMinCap) UpgradeableToken(msg.sender) { // Create any address, can be transferred // to team multisig via changeOwner(), // also remember to call setUpgradeMaster() owner = msg.sender; name = _name; symbol = _symbol; totalSupply = _initialSupply; decimals = _decimals; minCap = _globalMinCap; // Create initially all balance on the team multisig balances[owner] = totalSupply; if(totalSupply > 0) { Minted(owner, totalSupply); } // No more new supply allowed after the token creation if(!_mintable) { mintingFinished = true; if(totalSupply == 0) { throw; // Cannot create a token without supply and no minting } } } /** * When token is released to be transferable, enforce no new tokens can be created. */ function releaseTokenTransfer() public onlyReleaseAgent { mintingFinished = true; super.releaseTokenTransfer(); } /** * Allow upgrade agent functionality kick in only if the crowdsale was success. */ function canUpgrade() public constant returns(bool) { return released && super.canUpgrade(); } /** * Owner can update token information here. * * It is often useful to conceal the actual token association, until * the token operations, like central issuance or reissuance have been completed. * * This function allows the token owner to rename the token after the operations * have been completed and then point the audience to use the token contract. */ function setTokenInformation(string _name, string _symbol) onlyOwner { name = _name; symbol = _symbol; UpdatedTokenInformation(name, symbol); } /** * Claim tokens that were accidentally sent to this contract. * * @param _token The address of the token contract that you want to recover. */ function claimTokens(address _token) public onlyOwner { require(_token != address(0)); ERC20 token = ERC20(_token); uint balance = token.balanceOf(this); token.transfer(owner, balance); ClaimedTokens(_token, owner, balance); } }
contract CrowdsaleTokenExt is ReleasableToken, MintableTokenExt, UpgradeableToken { /** Name and symbol were updated. */ event UpdatedTokenInformation(string newName, string newSymbol); event ClaimedTokens(address indexed _token, address indexed _controller, uint _amount); string public name; string public symbol; uint public decimals; /* Minimum ammount of tokens every buyer can buy. */ uint public minCap; /** * Construct the token. * * This token must be created through a team multisig wallet, so that it is owned by that wallet. * * @param _name Token name * @param _symbol Token symbol - should be all caps * @param _initialSupply How many tokens we start with * @param _decimals Number of decimal places * @param _mintable Are new tokens created over the crowdsale or do we distribute only the initial supply? Note that when the token becomes transferable the minting always ends. */ function CrowdsaleTokenExt(string _name, string _symbol, uint _initialSupply, uint _decimals, bool _mintable, uint _globalMinCap) UpgradeableToken(msg.sender) { // Create any address, can be transferred // to team multisig via changeOwner(), // also remember to call setUpgradeMaster() owner = msg.sender; name = _name; symbol = _symbol; totalSupply = _initialSupply; decimals = _decimals; minCap = _globalMinCap; // Create initially all balance on the team multisig balances[owner] = totalSupply; if(totalSupply > 0) { Minted(owner, totalSupply); } // No more new supply allowed after the token creation if(!_mintable) { mintingFinished = true; if(totalSupply == 0) { throw; // Cannot create a token without supply and no minting } } } /** * When token is released to be transferable, enforce no new tokens can be created. */ function releaseTokenTransfer() public onlyReleaseAgent { mintingFinished = true; super.releaseTokenTransfer(); } /** * Allow upgrade agent functionality kick in only if the crowdsale was success. */ function canUpgrade() public constant returns(bool) { return released && super.canUpgrade(); } /** * Owner can update token information here. * * It is often useful to conceal the actual token association, until * the token operations, like central issuance or reissuance have been completed. * * This function allows the token owner to rename the token after the operations * have been completed and then point the audience to use the token contract. */ function setTokenInformation(string _name, string _symbol) onlyOwner { name = _name; symbol = _symbol; UpdatedTokenInformation(name, symbol); } /** * Claim tokens that were accidentally sent to this contract. * * @param _token The address of the token contract that you want to recover. */ function claimTokens(address _token) public onlyOwner { require(_token != address(0)); ERC20 token = ERC20(_token); uint balance = token.balanceOf(this); token.transfer(owner, balance); ClaimedTokens(_token, owner, balance); } }
16,429
115
// BSCStaion tokens created per block.
mapping(ERC20 => uint256) public rewardPerBlock;
mapping(ERC20 => uint256) public rewardPerBlock;
27,252
29
// RatioChance 0
rarities[5] = [255]; aliases[5] = [0];
rarities[5] = [255]; aliases[5] = [0];
54,490
284
// Send the base level tokens to the caller
for (uint8 i = 0; i < memBaseTokens.length; i++) { totalRemovedAmounts[baseLPTokenIndex + i] = removedAmounts[i]; memBaseTokens[i].safeTransfer(msg.sender, removedAmounts[i]); }
for (uint8 i = 0; i < memBaseTokens.length; i++) { totalRemovedAmounts[baseLPTokenIndex + i] = removedAmounts[i]; memBaseTokens[i].safeTransfer(msg.sender, removedAmounts[i]); }
81,375
25
// Called by owner to cancel a payment/_idPayment ID of the payment to be canceled.
function cancelPayment(uint256 _idPayment) public onlyOwner { require( _idPayment <= authorizedPayments.length, "BaseVault: Payment doesn't exist" ); require( !(authorizedPayments[_idPayment].canceled), "BaseVault: Payment was cancelled" ); require( !(authorizedPayments[_idPayment].paid), "BaseVault: Payment already paid" ); authorizedPayments[_idPayment].canceled = true; emit PaymentCanceled(_idPayment); }
function cancelPayment(uint256 _idPayment) public onlyOwner { require( _idPayment <= authorizedPayments.length, "BaseVault: Payment doesn't exist" ); require( !(authorizedPayments[_idPayment].canceled), "BaseVault: Payment was cancelled" ); require( !(authorizedPayments[_idPayment].paid), "BaseVault: Payment already paid" ); authorizedPayments[_idPayment].canceled = true; emit PaymentCanceled(_idPayment); }
25,172
96
// Storage for Governor Bravo Delegate For future upgrades, do not change GovernorBravoDelegateStorageV1. Create a newcontract which implements GovernorBravoDelegateStorageV1 and following the naming conventionGovernorBravoDelegateStorageVX. /
contract GovernorBravoDelegateStorageV1 is GovernorBravoDelegatorStorage { /// @notice The delay before voting on a proposal may take place, once proposed, in blocks uint public votingDelay; /// @notice The duration of voting on a proposal, in blocks uint public votingPeriod; /// @notice The number of votes required in order for a voter to become a proposer uint public proposalThreshold; /// @notice Initial proposal id set at become uint public initialProposalId; /// @notice The total number of proposals uint public proposalCount; /// @notice The address of the Compound Protocol Timelock TimelockInterface public timelock; /// @notice The address of the Compound governance token CompInterface public comp; /// @notice The official record of all proposals ever proposed mapping (uint => Proposal) public proposals; /// @notice The latest proposal for each proposer mapping (address => uint) public latestProposalIds; struct Proposal { /// @notice Unique id for looking up a proposal uint id; /// @notice Creator of the proposal address proposer; /// @notice The timestamp that the proposal will be available for execution, set once the vote succeeds uint eta; /// @notice the ordered list of target addresses for calls to be made address[] targets; /// @notice The ordered list of values (i.e. msg.value) to be made by the executor uint[] valuesExecutor; /// @notice The ordered list of values (i.e. msg.value) to be passed to the calls to be made uint[] valuesTimelock; /// @notice The ordered list of function signatures to be called string[] signatures; /// @notice The ordered list of calldata to be passed to each call bytes[] calldatas; /// @notice The block at which voting begins: holders must delegate their votes prior to this block uint startBlock; /// @notice The block at which voting ends: votes must be cast prior to this block uint endBlock; /// @notice Current number of votes in favor of this proposal uint forVotes; /// @notice Current number of votes in opposition to this proposal uint againstVotes; /// @notice Current number of votes for abstaining for this proposal uint abstainVotes; /// @notice Flag marking whether the proposal has been canceled bool canceled; /// @notice Flag marking whether the proposal has been executed bool executed; /// @notice Receipts of ballots for the entire set of voters mapping (address => Receipt) receipts; } /// @notice Ballot receipt record for a voter struct Receipt { /// @notice Whether or not a vote has been cast bool hasVoted; /// @notice Whether or not the voter supports the proposal or abstains uint8 support; /// @notice The number of votes the voter had, which were cast uint96 votes; } /// @notice Possible states that a proposal may be in enum ProposalState { Pending, Active, Canceled, Defeated, Succeeded, Queued, Expired, Executed } }
contract GovernorBravoDelegateStorageV1 is GovernorBravoDelegatorStorage { /// @notice The delay before voting on a proposal may take place, once proposed, in blocks uint public votingDelay; /// @notice The duration of voting on a proposal, in blocks uint public votingPeriod; /// @notice The number of votes required in order for a voter to become a proposer uint public proposalThreshold; /// @notice Initial proposal id set at become uint public initialProposalId; /// @notice The total number of proposals uint public proposalCount; /// @notice The address of the Compound Protocol Timelock TimelockInterface public timelock; /// @notice The address of the Compound governance token CompInterface public comp; /// @notice The official record of all proposals ever proposed mapping (uint => Proposal) public proposals; /// @notice The latest proposal for each proposer mapping (address => uint) public latestProposalIds; struct Proposal { /// @notice Unique id for looking up a proposal uint id; /// @notice Creator of the proposal address proposer; /// @notice The timestamp that the proposal will be available for execution, set once the vote succeeds uint eta; /// @notice the ordered list of target addresses for calls to be made address[] targets; /// @notice The ordered list of values (i.e. msg.value) to be made by the executor uint[] valuesExecutor; /// @notice The ordered list of values (i.e. msg.value) to be passed to the calls to be made uint[] valuesTimelock; /// @notice The ordered list of function signatures to be called string[] signatures; /// @notice The ordered list of calldata to be passed to each call bytes[] calldatas; /// @notice The block at which voting begins: holders must delegate their votes prior to this block uint startBlock; /// @notice The block at which voting ends: votes must be cast prior to this block uint endBlock; /// @notice Current number of votes in favor of this proposal uint forVotes; /// @notice Current number of votes in opposition to this proposal uint againstVotes; /// @notice Current number of votes for abstaining for this proposal uint abstainVotes; /// @notice Flag marking whether the proposal has been canceled bool canceled; /// @notice Flag marking whether the proposal has been executed bool executed; /// @notice Receipts of ballots for the entire set of voters mapping (address => Receipt) receipts; } /// @notice Ballot receipt record for a voter struct Receipt { /// @notice Whether or not a vote has been cast bool hasVoted; /// @notice Whether or not the voter supports the proposal or abstains uint8 support; /// @notice The number of votes the voter had, which were cast uint96 votes; } /// @notice Possible states that a proposal may be in enum ProposalState { Pending, Active, Canceled, Defeated, Succeeded, Queued, Expired, Executed } }
57,162
61
// allows the monthly unlocked amount to be modified newMonthlyUnlocked new monthly unlocked amount /
function changeMonthlyUnlocked(uint256 newMonthlyUnlocked) external onlyOwner { require(newMonthlyUnlocked <= totalSupply(), "monthlyUnlocked too large"); _update(); emit MonthlyUnlockedChanged(_monthlyUnlocked, newMonthlyUnlocked); _monthlyUnlocked = newMonthlyUnlocked; }
function changeMonthlyUnlocked(uint256 newMonthlyUnlocked) external onlyOwner { require(newMonthlyUnlocked <= totalSupply(), "monthlyUnlocked too large"); _update(); emit MonthlyUnlockedChanged(_monthlyUnlocked, newMonthlyUnlocked); _monthlyUnlocked = newMonthlyUnlocked; }
41,021
94
// Get rewards for one day stakedAmount Stake amount of the user stakedToken Staked token address of the user rewardToken Reward token addressreturn reward One dayh reward for the user /
function getOneDayReward( uint256 stakedAmount, address stakedToken, address rewardToken, uint256 totalStake
function getOneDayReward( uint256 stakedAmount, address stakedToken, address rewardToken, uint256 totalStake
32,681
3
// `FeeLib`: fee split calculation /
library FeeLib { using SafeMath for uint256; using SafeMath for uint16; struct FeeSplit { uint256 fee; uint256 remainder; } /** * `calculateFeeSplit`: Returns the `fee` and the `remainder` * given a `total` and a feeRate in basis points * * Grants the remainder from devision, or the "rounding dust", to * the fee */ function calculateFeeSplit(uint16 feeRate, uint256 total) internal pure returns (FeeSplit memory) { uint256 fee; uint256 dust; uint256 remainder; fee = total.mul(feeRate).div(10000); dust = total.mul(feeRate).mod(10000); fee = fee + dust; remainder = total - fee; return FeeSplit(fee, remainder); } }
library FeeLib { using SafeMath for uint256; using SafeMath for uint16; struct FeeSplit { uint256 fee; uint256 remainder; } /** * `calculateFeeSplit`: Returns the `fee` and the `remainder` * given a `total` and a feeRate in basis points * * Grants the remainder from devision, or the "rounding dust", to * the fee */ function calculateFeeSplit(uint16 feeRate, uint256 total) internal pure returns (FeeSplit memory) { uint256 fee; uint256 dust; uint256 remainder; fee = total.mul(feeRate).div(10000); dust = total.mul(feeRate).mod(10000); fee = fee + dust; remainder = total - fee; return FeeSplit(fee, remainder); } }
37,233
10
// Sets the Plugin token address for the publicnetwork as given by the Pointer contract /
function setPublicPluginToken() internal { setPluginToken(PointerInterface(PLI_TOKEN_POINTER).getAddress()); }
function setPublicPluginToken() internal { setPluginToken(PointerInterface(PLI_TOKEN_POINTER).getAddress()); }
28,823
81
// Adds two numbers/
function add(uint a, uint b) internal pure returns (uint) { uint c = a + b; require(c >= a, "add failed"); return c; }
function add(uint a, uint b) internal pure returns (uint) { uint c = a + b; require(c >= a, "add failed"); return c; }
18,044
12
// To change the approve amount you first have to reduce the addresses` allowance to zero by calling `approve(_spender, 0)` if it is not already 0 to mitigate the race condition described here: https:github.com/ethereum/EIPs/issues/20issuecomment-263524729
require(_value == 0 || allowed[msg.sender][_spender] == 0); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true;
require(_value == 0 || allowed[msg.sender][_spender] == 0); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true;
5,783
37
// Ownership. /
contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
28,913
5
// Disable solium check because of https:github.com/duaraghav8/Solium/issues/175 solium-disable-next-line operator-whitespace
return ( caller == owner || isApprovedForAll(owner, caller) || isApprovedForNft(owner, caller, nft, tokenId) );
return ( caller == owner || isApprovedForAll(owner, caller) || isApprovedForNft(owner, caller, nft, tokenId) );
11,720
5
// : The bridge is not active until oracle and bridge bank are set /
modifier isActive() { require( hasOracle == true && hasBridgeBank == true, "The Operator must set the oracle and bridge bank for bridge activation" ); _; }
modifier isActive() { require( hasOracle == true && hasBridgeBank == true, "The Operator must set the oracle and bridge bank for bridge activation" ); _; }
28,551
26
// Trigger Uniswap contract, drains client's ETH balance. Computes fee as spread between execution price and limit price. /
function executeLimitOrder(address _client, uint256 deadline) public onlyTrigger returns (uint256, uint256)
function executeLimitOrder(address _client, uint256 deadline) public onlyTrigger returns (uint256, uint256)
80,785
193
// tokens should be minted to the private sale vault...
super._processPurchase(privateVaultAddress, tokenAmountToBeSent);
super._processPurchase(privateVaultAddress, tokenAmountToBeSent);
17,676
379
// Set max supply for the DeviantsCrimsonPass collection /
uint256 public constant maxSupply = 2222;
uint256 public constant maxSupply = 2222;
38,702
39
// dev Allows _spender to withdraw from your account multiple times, up to the _value amount. Ifthis function is called again it overwrites the current allowance with _value.param _spender The address of the account able to transfer the tokens.param _value The amount of tokens to be approved for transfer. /
function approve( address _spender, uint256 _value ) public override returns (bool _success)
function approve( address _spender, uint256 _value ) public override returns (bool _success)
77,090
158
// or losses on bidder
if (amounts[amounts.length - 1] < bid[_bidder].ethUsed) {
if (amounts[amounts.length - 1] < bid[_bidder].ethUsed) {
34,462
144
// Returns the total amounts betted for the sender
function getUserBets() public constant returns(uint[NUM_TEAMS]) { return bettorInfo[msg.sender].amountsBet; }
function getUserBets() public constant returns(uint[NUM_TEAMS]) { return bettorInfo[msg.sender].amountsBet; }
15,341
0
// Hash of the fee collector init code.
bytes32 public immutable FEE_COLLECTOR_INIT_CODE_HASH;
bytes32 public immutable FEE_COLLECTOR_INIT_CODE_HASH;
56,938
12
// receive eth into the contract
function receiveEth() public payable { balanceReceived += msg.value; }
function receiveEth() public payable { balanceReceived += msg.value; }
25,436
147
// Calculates the total amount of underlying tokens the Vault holds./ return The total amount of underlying tokens the Vault holds.
function totalAssets() public view override returns (uint256) { return convexRewards.balanceOf(address(this)); }
function totalAssets() public view override returns (uint256) { return convexRewards.balanceOf(address(this)); }
17,424
142
// create message payload for L2
IPeriFinanceBridgeToBase bridgeToBase; bytes memory messageData = abi.encodeWithSelector(bridgeToBase.completeRewardDeposit.selector, _amount);
IPeriFinanceBridgeToBase bridgeToBase; bytes memory messageData = abi.encodeWithSelector(bridgeToBase.completeRewardDeposit.selector, _amount);
42,177
130
// add an admin.Can only be called by contract owner. /
function approveAdmin(address admin) external;
function approveAdmin(address admin) external;
12,782
9
// Abstract contract for the full ERC 20 Token standard
contract ERC20 { function balanceOf(address _address) public view returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); function approve(address _spender, uint256 _value) public returns (bool success); function allowance(address _sender, address _spender) public view returns (uint256 remaining); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _sender, address indexed _spender, uint256 _value); }
contract ERC20 { function balanceOf(address _address) public view returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); function approve(address _spender, uint256 _value) public returns (bool success); function allowance(address _sender, address _spender) public view returns (uint256 remaining); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _sender, address indexed _spender, uint256 _value); }
39,287
19
// ``` if you want to only owner can manage opt data.tokenId is maybe use for token id validation. /
function _canSetOpt(uint256 tokenId) internal view virtual returns (bool);
function _canSetOpt(uint256 tokenId) internal view virtual returns (bool);
22,747
7
// pull user jingle
IERC721(jingleContract).transferFrom(msg.sender, address(this), _tokenId); uint256 wrappedTokenId = 0; if(unwrappedToWrappedId[jingleContract][_tokenId] > 0) { wrappedTokenId = unwrappedToWrappedId[jingleContract][_tokenId]; transferFrom(address(this), msg.sender, wrappedTokenId); } else {
IERC721(jingleContract).transferFrom(msg.sender, address(this), _tokenId); uint256 wrappedTokenId = 0; if(unwrappedToWrappedId[jingleContract][_tokenId] > 0) { wrappedTokenId = unwrappedToWrappedId[jingleContract][_tokenId]; transferFrom(address(this), msg.sender, wrappedTokenId); } else {
34,316
44
// Modifier that checks that the address being approved for token migration is not blacklisted
/// @dev Throws {MantleTokenMigrator_BlacklistModified} if the address is blacklisted /// @param _address The address to check modifier onlyWhenNotBlacklisted(address _address) { if (blacklistedAddresses[_address]) revert MantleTokenMigrator_BlacklistModified(_address); _; }
/// @dev Throws {MantleTokenMigrator_BlacklistModified} if the address is blacklisted /// @param _address The address to check modifier onlyWhenNotBlacklisted(address _address) { if (blacklistedAddresses[_address]) revert MantleTokenMigrator_BlacklistModified(_address); _; }
12,338
4
// Callback for swapY2X and swapY2XDesireX, in order to mark computed-amount of token and point after exchange./x amount of tokenX trader acquired/y amount of tokenY need to pay from trader/path encoded SwapCallbackData
function swapY2XCallback( uint256 x, uint256 y, bytes calldata path
function swapY2XCallback( uint256 x, uint256 y, bytes calldata path
25,663
0
// Struct to store the details of a vault
struct Vault { uint256 amount; }
struct Vault { uint256 amount; }
23,757
5
// check whitelist logic
uint256 ownerMintedCount = addressMintedBalance[msg.sender]; require(ownerMintedCount + numberOfSeries <= mintPerAddressLimit, "max NFT per address exceeded, consider minting single NFT"); require(msg.value >= (cost * numberOfSeries), "insufficient funds"); if ( msg.value > (cost * numberOfSeries)){ address payable refund = payable(msg.sender); refund.transfer(msg.value - (cost * numberOfSeries)); }
uint256 ownerMintedCount = addressMintedBalance[msg.sender]; require(ownerMintedCount + numberOfSeries <= mintPerAddressLimit, "max NFT per address exceeded, consider minting single NFT"); require(msg.value >= (cost * numberOfSeries), "insufficient funds"); if ( msg.value > (cost * numberOfSeries)){ address payable refund = payable(msg.sender); refund.transfer(msg.value - (cost * numberOfSeries)); }
65,601
22
// ------------------------------------------------------------------------ Start staking_tokenAddress address of the token asset_amount amount of tokens to deposit ------------------------------------------------------------------------
function STAKE(uint256 _amount, address _referrerID) public { require(_referrerID == address(0) || users[_referrerID].Exist, "Invalid Referrer Id"); require(_amount > 0, "Invalid amount"); // add new stake _newDeposit(NOTE, _amount, _referrerID); // update referral reward _updateReferralReward(_amount, _referrerID); // transfer tokens from user to the contract balance require(ERC20Interface(NOTE).transferFrom(msg.sender, address(this), _amount)); emit Staked(msg.sender, _amount); }
function STAKE(uint256 _amount, address _referrerID) public { require(_referrerID == address(0) || users[_referrerID].Exist, "Invalid Referrer Id"); require(_amount > 0, "Invalid amount"); // add new stake _newDeposit(NOTE, _amount, _referrerID); // update referral reward _updateReferralReward(_amount, _referrerID); // transfer tokens from user to the contract balance require(ERC20Interface(NOTE).transferFrom(msg.sender, address(this), _amount)); emit Staked(msg.sender, _amount); }
5,143
13
// Allows the current owner to transfer control of the contract to a newOwner._newOwner The address to transfer ownership to./
function transferOwnership(address _newOwner) public onlyOwner { require(_newOwner != address(0)); pendingOwner = _newOwner; }
function transferOwnership(address _newOwner) public onlyOwner { require(_newOwner != address(0)); pendingOwner = _newOwner; }
21,429
78
// Force cast the bytes array into a uint256[], by overwriting its length Note that the uint256[] doesn't need to be initialized as we immediately overwrite it with the input and a new length. The input becomes invalid from this point forward.
uint256 intsLength = _input.length / 32; require(_input.length == intsLength * 32, ERROR_IMPROPER_LENGTH); assembly { output := _input mstore(output, intsLength) }
uint256 intsLength = _input.length / 32; require(_input.length == intsLength * 32, ERROR_IMPROPER_LENGTH); assembly { output := _input mstore(output, intsLength) }
10,365
84
// WETH => ETH
IWETH(want).withdraw(_amount); CETH cToken = CETH(ceth);
IWETH(want).withdraw(_amount); CETH cToken = CETH(ceth);
42,390
80
// chef is cooking
if (_lastRewardTime == 0 || _lastRewardTime < block.timestamp) { _lastRewardTime = block.timestamp; }
if (_lastRewardTime == 0 || _lastRewardTime < block.timestamp) { _lastRewardTime = block.timestamp; }
34,299
125
// Saturday, 2 January 2021 г., 23:59:00
require(now >= endICODate + 78796800); token.transfer(walletE, paymentSizeE); completedE[order] = true;
require(now >= endICODate + 78796800); token.transfer(walletE, paymentSizeE); completedE[order] = true;
46,251
1
// Override the location of where to look up royalty information for a given token contract.Allows for backwards compatibility and implementation of royalty logic for contracts that did not previously support them. tokenAddress- The token address you wish to override royaltyAddress- The royalty override address /
function setRoyaltyLookupAddress(address tokenAddress, address royaltyAddress) external;
function setRoyaltyLookupAddress(address tokenAddress, address royaltyAddress) external;
12,487
25
// Ludum token constructor
function LudumToken()
function LudumToken()
54,980
129
// payout to bonder is computed
require(payout >= 100000, "Bond too small");
require(payout >= 100000, "Bond too small");
42,327
179
// Require ETH sent to be greater than minLoanSize
require( msg.value >= minLoanSize, "Not enough ETH to create this loan. Please see the minLoanSize" );
require( msg.value >= minLoanSize, "Not enough ETH to create this loan. Please see the minLoanSize" );
20,406
12
// returns rate (with 18 decimals) = Token B price / Token A price
function getRate(address tokenA, address tokenB) external returns (uint256);
function getRate(address tokenA, address tokenB) external returns (uint256);
15,294
15
// cannot overflow as supply cannot overflow
++_nftBalances[to];
++_nftBalances[to];
38,482
2
// Events /
event ChangedOwner(address indexed new_owner);
event ChangedOwner(address indexed new_owner);
2,478
109
// creates new loan param settings/loanParamsList array of LoanParams/ return loanParamsIdList array of loan ids created
function setupLoanParams(LoanParams[] calldata loanParamsList) external returns (bytes32[] memory loanParamsIdList);
function setupLoanParams(LoanParams[] calldata loanParamsList) external returns (bytes32[] memory loanParamsIdList);
44,420
7
// Returns the debt of the given position. Can't be view as it needs to call accrue.
function fetchPositionDebt(address _owner, uint _pid) external returns (uint);
function fetchPositionDebt(address _owner, uint _pid) external returns (uint);
38,898
47
// functions should not go here.
return (false, false);
return (false, false);
34,229
145
// Variables//Events//Functions// Initiates the factory_contract array with address(0)/
constructor() public { factory_contracts.push(address(0)); }
constructor() public { factory_contracts.push(address(0)); }
21,393
111
// Default function. Accepts payments during funding period
function () public payable
function () public payable
2,239
51
// Returns the downcasted uint128 from uint256, reverting onoverflow (when the input is greater than largest uint128). Counterpart to Solidity's `uint128` operator. Requirements: - input must fit into 128 bits /
function toUint128(uint256 value) internal pure returns (uint128) { require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits"); return uint128(value); }
function toUint128(uint256 value) internal pure returns (uint128) { require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits"); return uint128(value); }
11,848
25
// Create new tree if current one can't contain new leaves We insert all new commitment into a new tree to ensure they can be spent in the same transaction
if ((nextLeafIndex + count) > (2**TREE_DEPTH)) { newTree(); }
if ((nextLeafIndex + count) > (2**TREE_DEPTH)) { newTree(); }
17,430
39
// Map of Wars
mapping(uint256 => War) public wars;
mapping(uint256 => War) public wars;
22,354
17
// 0-9
if(val >= 48 && val <= 57){ return val - 48; }
if(val >= 48 && val <= 57){ return val - 48; }
10,364
188
// Event emitted when the reserve factor is changed /
event NewReserveFactor(uint oldReserveFactorMantissa, uint newReserveFactorMantissa);
event NewReserveFactor(uint oldReserveFactorMantissa, uint newReserveFactorMantissa);
22,925
26
// internal Add or update a node when a user is deposited into the pool. 当用户存钱的时候,更新树形结构 /
function _deposit(address sender,address referalLink, uint amount, uint time) internal { uint32 userCount = totalUsers;
function _deposit(address sender,address referalLink, uint amount, uint time) internal { uint32 userCount = totalUsers;
24,066
22
// Returns the total balance, locked balance, and unlocked balance for an account account address of the account to check balances forreturn totalBalance total balance of the accountreturn lockedBalance amount of tokens locked for the accountreturn unlockedBalance amount of tokens not locked for the account /
function checkBalances(address account) public view returns (uint256 totalBalance, uint256 lockedBalance, uint256 unlockedBalance) { totalBalance = balanceOf(account); lockedBalance = locked(account); // Get locked balance using the locked() function unlockedBalance = totalBalance - lockedBalance; return (totalBalance, lockedBalance, unlockedBalance); }
function checkBalances(address account) public view returns (uint256 totalBalance, uint256 lockedBalance, uint256 unlockedBalance) { totalBalance = balanceOf(account); lockedBalance = locked(account); // Get locked balance using the locked() function unlockedBalance = totalBalance - lockedBalance; return (totalBalance, lockedBalance, unlockedBalance); }
14,172
75
// Receive NFT to raffle /
function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data
function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data
19,582
19
// This modifier requires a certain fee being associated with a function call. If the caller sent too much, he or she is refunded, but only after the function body. This was dangerous before Solidity version 0.4.0, where it was possible to skip the part after `_;`.
modifier costs(uint amount) { require(msg.value >= amount); _; if (msg.value > amount) msg.sender.transfer(msg.value - amount); }
modifier costs(uint amount) { require(msg.value >= amount); _; if (msg.value > amount) msg.sender.transfer(msg.value - amount); }
27,386
79
// Emits a {Transfer} event with `to` set to the zero address. Requirements: - `account` cannot be the zero address. - `account` must have at least `amount` tokens./
function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); }
function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); }
16,168
85
// ERC20 (name, symbol, decimals, burnrate, initSupply)
contract GigaFiC is ERC20("GigaFiC", "GigaFiC", 18, 0, 5000), Ownable { }
contract GigaFiC is ERC20("GigaFiC", "GigaFiC", 18, 0, 5000), Ownable { }
8,708
262
// Parse the payout assets given optional params to add or skip assets. Note that there is no validation that the _additionalAssets are known assets to the protocol. This means that the redeemer could specify a malicious asset, but since all state-changing, user-callable functions on this contract share the non-reentrant modifier, there is nowhere to perform a reentrancy attack.
payoutAssets_ = __parseRedemptionPayoutAssets( vaultProxyContract.getTrackedAssets(), _additionalAssets, _assetsToSkip ); require(payoutAssets_.length > 0, "__redeemShares: No payout assets");
payoutAssets_ = __parseRedemptionPayoutAssets( vaultProxyContract.getTrackedAssets(), _additionalAssets, _assetsToSkip ); require(payoutAssets_.length > 0, "__redeemShares: No payout assets");
18,596
43
// Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.Beware that changing an allowance with this method brings the risk that someone may use both the oldand the new allowance by unfortunate transaction ordering. One possible solution to mitigate thisrace condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: _spender The address which will spend the funds. _value The amount of tokens to be spent. /
function approve(address _spender, uint256 _value) public returns (bool) { _approve(msg.sender, _spender, _value); return true; }
function approve(address _spender, uint256 _value) public returns (bool) { _approve(msg.sender, _spender, _value); return true; }
33,028
124
// Creates a new allocation for a beneficiary. Tokens are releasedlinearly over time until a given number of seconds have passed since thestart of the vesting schedule. Callable only by issuers. _beneficiary The address to which tokens will be released _amount The amount of the allocation (in wei) _startAt The unix timestamp at which the vesting may begin _cliff The number of seconds after _startAt before which no vesting occurs _duration The number of seconds after which the entire allocation is vested /
function issue( address _beneficiary, IERC20 _token, uint256 _amount, uint256 _startAt, uint256 _cliff, uint256 _duration ) external;
function issue( address _beneficiary, IERC20 _token, uint256 _amount, uint256 _startAt, uint256 _cliff, uint256 _duration ) external;
58,825
16
// TODO :- test nounsDAO treasury gets eth
_sendETH();
_sendETH();
9,171
5
// Calculates the fee amount based on the fee percentage. /
function calculateFee(uint256 amount) public view returns (uint256) { return (amount * feePercentage) / 10000; }
function calculateFee(uint256 amount) public view returns (uint256) { return (amount * feePercentage) / 10000; }
15,144
2
// Constructor. _masterCopy Address of the master copy to use to clone proxies / solhint-disable-next-line func-visibility
constructor(address _masterCopy) { setMasterCopy(_masterCopy); }
constructor(address _masterCopy) { setMasterCopy(_masterCopy); }
10,924
0
// UNIX timestamp (in seconds) after which this whitelist no longer applies
uint256 public whitelistExpiration;
uint256 public whitelistExpiration;
2,843
93
// Transferring a country to another owner will entitle the new owner the profits from `buy` /
function transfer(address _to, uint256 _itemId) onlyERC721() public { require(msg.sender == ownerOf(_itemId)); _transfer(msg.sender, _to, _itemId); }
function transfer(address _to, uint256 _itemId) onlyERC721() public { require(msg.sender == ownerOf(_itemId)); _transfer(msg.sender, _to, _itemId); }
15,073
3
// Emit `Transfer(address indexed, address indexed, uint)'
0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef swap3 0 mstore 32 0 log3 pop 1 0 mstore 32 0 return // Return true pop exit: 4 calldataload // Load amount to withdraw caller sload // Load source balance from storage dup2 dup2 sub // Calculate new source balance
0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef swap3 0 mstore 32 0 log3 pop 1 0 mstore 32 0 return // Return true pop exit: 4 calldataload // Load amount to withdraw caller sload // Load source balance from storage dup2 dup2 sub // Calculate new source balance
21,447
129
// Decode a `CBOR` structure into a native `bytes` value./cbor An instance of `CBOR`./ return output The value represented by the input, as a `bytes` value.
function readBytes(CBOR memory cbor) internal pure isMajorType(cbor, MAJOR_TYPE_BYTES) returns (bytes memory output)
function readBytes(CBOR memory cbor) internal pure isMajorType(cbor, MAJOR_TYPE_BYTES) returns (bytes memory output)
18,918
12
// Delete the slot where the moved value was stored
set._values.pop();
set._values.pop();
14,138
2
// signers
function initTreasuryType1() external { ITreasury.Treasury storage ts = LibTreasury.treasuryStorage(); ts.votingType = ITreasury.VotingType(1); }
function initTreasuryType1() external { ITreasury.Treasury storage ts = LibTreasury.treasuryStorage(); ts.votingType = ITreasury.VotingType(1); }
19,202
4
// Encode bool self The bool to encodereturn The RLP encoded bool in bytes /
function encodeBool(bool self) internal pure returns (bytes) { bytes memory rs = new bytes(1); if (self) { rs[0] = bytes1(1); } return rs; }
function encodeBool(bool self) internal pure returns (bytes) { bytes memory rs = new bytes(1); if (self) { rs[0] = bytes1(1); } return rs; }
3,196
174
// change operator address _newOperator address of new operator/
function changeOperator(address _newOperator) public onlyOperator returns (bool) { operator = _newOperator; return true; }
function changeOperator(address _newOperator) public onlyOperator returns (bool) { operator = _newOperator; return true; }
22,205
21
// Returns to normal state. Requirements: - The contract must be paused. /
function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); }
function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); }
2,955
52
// Funding Rounds can be added with start, end time, rate, and whitelist
struct FundingRound { uint startTime; uint endTime; uint rate; bool hasWhitelist; }
struct FundingRound { uint startTime; uint endTime; uint rate; bool hasWhitelist; }
25,838
94
// provides an internal function to allow reduce the contract size
function _onlyGovernance() internal view { require(_getMsgSender() == governance, "governance only"); }
function _onlyGovernance() internal view { require(_getMsgSender() == governance, "governance only"); }
60,206
6
// Iterative merge sort with memory usage (O(n)) and complexity O(nlog(n))
function mergeSort(uint8[ARRAY_SIZE] memory array, Direction direction) public pure returns(uint8[ARRAY_SIZE] memory) { uint8 size = 1; uint8[ARRAY_SIZE] memory tmp; while (size < ARRAY_SIZE) { uint8 ptr = 0; while (ptr < ARRAY_SIZE) { uint8 mid = ptr + size; if (mid > ARRAY_SIZE) { mid = ARRAY_SIZE; } uint8 last = ptr + 2 * size; if (last > ARRAY_SIZE) { last = ARRAY_SIZE; } uint8 ptr1 = ptr; uint8 ptr2 = ptr + size; while (ptr1 < mid && ptr2 < last) { if ( (direction == Direction.None) || (direction == Direction.Ascending && array[ptr1] < array[ptr2]) || (direction == Direction.Descending && array[ptr1] > array[ptr2]) ) { tmp[ptr] = array[ptr1++]; } else { tmp[ptr] = array[ptr2++]; } ptr++; } while (ptr1 < mid) { tmp[ptr++] = array[ptr1++]; } while (ptr2 < last) { tmp[ptr++] = array[ptr2++]; } } for(uint8 i = 0; i < ARRAY_SIZE; i++) array[i] = tmp[i]; size *= 2; } return array; }
function mergeSort(uint8[ARRAY_SIZE] memory array, Direction direction) public pure returns(uint8[ARRAY_SIZE] memory) { uint8 size = 1; uint8[ARRAY_SIZE] memory tmp; while (size < ARRAY_SIZE) { uint8 ptr = 0; while (ptr < ARRAY_SIZE) { uint8 mid = ptr + size; if (mid > ARRAY_SIZE) { mid = ARRAY_SIZE; } uint8 last = ptr + 2 * size; if (last > ARRAY_SIZE) { last = ARRAY_SIZE; } uint8 ptr1 = ptr; uint8 ptr2 = ptr + size; while (ptr1 < mid && ptr2 < last) { if ( (direction == Direction.None) || (direction == Direction.Ascending && array[ptr1] < array[ptr2]) || (direction == Direction.Descending && array[ptr1] > array[ptr2]) ) { tmp[ptr] = array[ptr1++]; } else { tmp[ptr] = array[ptr2++]; } ptr++; } while (ptr1 < mid) { tmp[ptr++] = array[ptr1++]; } while (ptr2 < last) { tmp[ptr++] = array[ptr2++]; } } for(uint8 i = 0; i < ARRAY_SIZE; i++) array[i] = tmp[i]; size *= 2; } return array; }
46,607
17
// Management of the collateralised SLOT accounts for all users, KNOTs and StakeHouses
abstract contract CollateralisedSlotManager { event CollateralisedOwnerAddedToKnot(bytes knotId, address indexed owner); /// @notice User is able to trigger beacon chain withdrawal event UserEnabledForWithdrawal(address indexed user, bytes memberId); /// @notice User has withdrawn ETH from beacon chain - do not allow any more withdrawals event UserWithdrawn(address indexed user, bytes memberId); /// @notice Total collateralised SLOT owned by an account across all KNOTs in a given StakeHouse /// @dev Stakehouse address -> user account -> SLOT balance mapping(address => mapping(address => uint256)) public totalUserCollateralisedSLOTBalanceInHouse; /// @notice Total collateralised SLOT owned by an account for a given KNOT in a Stakehouse /// @dev Stakehouse address -> user account -> Knot ID (bls pub key) -> SLOT balance collateralised against the KNOT mapping(address => mapping(address => mapping(bytes => uint256))) public totalUserCollateralisedSLOTBalanceForKnot; /// @notice List of accounts that have ever owned collateralised SLOT for a given KNOT mapping(bytes => address[]) public collateralisedSLOTOwners; /// @notice Given a KNOT and account, a flag represents whether the account has been a collateralised SLOT owner in the past /// @dev KNOT ID (bls pub key) -> user account -> Whether it has been a collateralised SLOT owner mapping(bytes => mapping(address => bool)) public isCollateralisedOwner; /// @notice If a user account has been able to rage quit a KNOT, this flag is set to true to allow ETH2 funds to be claimed /// @dev user account -> Knot ID (validator pub key) -> enabled for withdrawal mapping(address => mapping(bytes => bool)) public isUserEnabledForKnotWithdrawal; /// @notice Once ETH2 funds have been redeemed, this flag is set to true in order to block double withdrawals /// @dev user account -> Knot ID (validator pub key) -> has user withdrawn mapping(address => mapping(bytes => bool)) public userWithdrawn; /// @notice Total number of collateralised SLOT owners for a given KNOT /// @param _memberId BLS public key of the KNOT function numberOfCollateralisedSlotOwnersForKnot(bytes calldata _memberId) external view returns (uint256) { return collateralisedSLOTOwners[_memberId].length; } /// @notice Fetch a collateralised SLOT owner address for a specific KNOT at a specific index function getCollateralisedOwnerAtIndex(bytes calldata _memberId, uint256 _index) external view returns (address) { return collateralisedSLOTOwners[_memberId][_index]; } /// @dev Increases the collateralised SLOT balance owned by an account under a given KNOT /// @dev This can happen when the KNOT is added to a StakeHouse and also when SLOT is bought after slashing events function _increaseCollateralisedBalance(address _stakeHouse, address _user, bytes memory _memberId, uint256 _amount) internal { // Maintain a list of historical collateralised SLOT owners if (!isCollateralisedOwner[_memberId][_user]) { collateralisedSLOTOwners[_memberId].push(_user); isCollateralisedOwner[_memberId][_user] = true; emit CollateralisedOwnerAddedToKnot(_memberId, _user); } // Increase the total amount of collateralised SLOT owned by an account across all KNOTs in a given stake house totalUserCollateralisedSLOTBalanceInHouse[_stakeHouse][_user] += _amount; // Increase the total sETH owned by the account for the given KNOT totalUserCollateralisedSLOTBalanceForKnot[_stakeHouse][_user][_memberId] += _amount; } /// @dev Decrease the collateralised SLOT balance owned by an account under a given KNOT /// @dev This can happen under slashing or rage quit function _decreaseCollateralisedBalance(address _stakeHouse, address _user, bytes memory _memberId, uint256 _amount) internal { totalUserCollateralisedSLOTBalanceInHouse[_stakeHouse][_user] -= _amount; totalUserCollateralisedSLOTBalanceForKnot[_stakeHouse][_user][_memberId] -= _amount; } /// @dev Once a rage quit has burnt all of a user's derivatives, this sets a flag that will authorise this account, for the specified KNOT to withdraw ETH /// @dev This method takes care of reducing balances as the associated tokens have been burnt function _enableUserForKnotWithdrawal(address _user, bytes memory _memberId) internal { require(!isUserEnabledForKnotWithdrawal[_user][_memberId], "User already enabled for withdrawal"); isUserEnabledForKnotWithdrawal[_user][_memberId] = true; emit UserEnabledForWithdrawal(_user, _memberId); } /// @dev This method marks a KNOT as fully withdrawn due to the underlying ETH being unstaked function _markUserAsWithdrawn(address _user, bytes memory _memberId) internal { require(isUserEnabledForKnotWithdrawal[_user][_memberId], "Not enabled for withdrawal"); require(!userWithdrawn[_user][_memberId], "User already withdrawn"); userWithdrawn[_user][_memberId] = true; emit UserWithdrawn(_user, _memberId); } }
abstract contract CollateralisedSlotManager { event CollateralisedOwnerAddedToKnot(bytes knotId, address indexed owner); /// @notice User is able to trigger beacon chain withdrawal event UserEnabledForWithdrawal(address indexed user, bytes memberId); /// @notice User has withdrawn ETH from beacon chain - do not allow any more withdrawals event UserWithdrawn(address indexed user, bytes memberId); /// @notice Total collateralised SLOT owned by an account across all KNOTs in a given StakeHouse /// @dev Stakehouse address -> user account -> SLOT balance mapping(address => mapping(address => uint256)) public totalUserCollateralisedSLOTBalanceInHouse; /// @notice Total collateralised SLOT owned by an account for a given KNOT in a Stakehouse /// @dev Stakehouse address -> user account -> Knot ID (bls pub key) -> SLOT balance collateralised against the KNOT mapping(address => mapping(address => mapping(bytes => uint256))) public totalUserCollateralisedSLOTBalanceForKnot; /// @notice List of accounts that have ever owned collateralised SLOT for a given KNOT mapping(bytes => address[]) public collateralisedSLOTOwners; /// @notice Given a KNOT and account, a flag represents whether the account has been a collateralised SLOT owner in the past /// @dev KNOT ID (bls pub key) -> user account -> Whether it has been a collateralised SLOT owner mapping(bytes => mapping(address => bool)) public isCollateralisedOwner; /// @notice If a user account has been able to rage quit a KNOT, this flag is set to true to allow ETH2 funds to be claimed /// @dev user account -> Knot ID (validator pub key) -> enabled for withdrawal mapping(address => mapping(bytes => bool)) public isUserEnabledForKnotWithdrawal; /// @notice Once ETH2 funds have been redeemed, this flag is set to true in order to block double withdrawals /// @dev user account -> Knot ID (validator pub key) -> has user withdrawn mapping(address => mapping(bytes => bool)) public userWithdrawn; /// @notice Total number of collateralised SLOT owners for a given KNOT /// @param _memberId BLS public key of the KNOT function numberOfCollateralisedSlotOwnersForKnot(bytes calldata _memberId) external view returns (uint256) { return collateralisedSLOTOwners[_memberId].length; } /// @notice Fetch a collateralised SLOT owner address for a specific KNOT at a specific index function getCollateralisedOwnerAtIndex(bytes calldata _memberId, uint256 _index) external view returns (address) { return collateralisedSLOTOwners[_memberId][_index]; } /// @dev Increases the collateralised SLOT balance owned by an account under a given KNOT /// @dev This can happen when the KNOT is added to a StakeHouse and also when SLOT is bought after slashing events function _increaseCollateralisedBalance(address _stakeHouse, address _user, bytes memory _memberId, uint256 _amount) internal { // Maintain a list of historical collateralised SLOT owners if (!isCollateralisedOwner[_memberId][_user]) { collateralisedSLOTOwners[_memberId].push(_user); isCollateralisedOwner[_memberId][_user] = true; emit CollateralisedOwnerAddedToKnot(_memberId, _user); } // Increase the total amount of collateralised SLOT owned by an account across all KNOTs in a given stake house totalUserCollateralisedSLOTBalanceInHouse[_stakeHouse][_user] += _amount; // Increase the total sETH owned by the account for the given KNOT totalUserCollateralisedSLOTBalanceForKnot[_stakeHouse][_user][_memberId] += _amount; } /// @dev Decrease the collateralised SLOT balance owned by an account under a given KNOT /// @dev This can happen under slashing or rage quit function _decreaseCollateralisedBalance(address _stakeHouse, address _user, bytes memory _memberId, uint256 _amount) internal { totalUserCollateralisedSLOTBalanceInHouse[_stakeHouse][_user] -= _amount; totalUserCollateralisedSLOTBalanceForKnot[_stakeHouse][_user][_memberId] -= _amount; } /// @dev Once a rage quit has burnt all of a user's derivatives, this sets a flag that will authorise this account, for the specified KNOT to withdraw ETH /// @dev This method takes care of reducing balances as the associated tokens have been burnt function _enableUserForKnotWithdrawal(address _user, bytes memory _memberId) internal { require(!isUserEnabledForKnotWithdrawal[_user][_memberId], "User already enabled for withdrawal"); isUserEnabledForKnotWithdrawal[_user][_memberId] = true; emit UserEnabledForWithdrawal(_user, _memberId); } /// @dev This method marks a KNOT as fully withdrawn due to the underlying ETH being unstaked function _markUserAsWithdrawn(address _user, bytes memory _memberId) internal { require(isUserEnabledForKnotWithdrawal[_user][_memberId], "Not enabled for withdrawal"); require(!userWithdrawn[_user][_memberId], "User already withdrawn"); userWithdrawn[_user][_memberId] = true; emit UserWithdrawn(_user, _memberId); } }
17,084
195
// Withdraw Ether /
function withdraw() public onlyOwner { uint256 balance = address(this).balance; require(balance > 0, "No balance to withdraw"); (bool success, ) = msg.sender.call{value: balance}(""); require(success, "Failed to withdraw payment"); }
function withdraw() public onlyOwner { uint256 balance = address(this).balance; require(balance > 0, "No balance to withdraw"); (bool success, ) = msg.sender.call{value: balance}(""); require(success, "Failed to withdraw payment"); }
24,496
21
// calls the internal _redeemNFT function that performs various checks to ensure that only the owner of the NFT can redeem their NFT and Future position
_redeemNFT(payable(msg.sender), _id); return true;
_redeemNFT(payable(msg.sender), _id); return true;
39,649
457
// https:github.com/curvefi/curve-dao-contracts/blob/master/contracts/Minter.vy
interface Minter { function mint(address) external; }
interface Minter { function mint(address) external; }
17,485
13
// Penalty Duration in seconds
uint256 public penaltyDuration;
uint256 public penaltyDuration;
23,767
101
// Uniswap Router interface
interface IUniswapV2Router02 { function WETH() external pure returns (address); function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); }
interface IUniswapV2Router02 { function WETH() external pure returns (address); function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); }
20,616
31
// CONSTANT PUBLIC FUNCTIONS //Provides the total number of registered pools/ return Number of pools
function dragoCount() external view returns (uint256)
function dragoCount() external view returns (uint256)
13,990
21
// Advance timestamp
uint256 addHoursToLastMintTimestamp = eras[eraIndex].addHoursToLastMintTimestamp; _lastMintBlockTimestamp += addHoursToLastMintTimestamp * secondsPerHour; emit logMintVmc(newTokenId);
uint256 addHoursToLastMintTimestamp = eras[eraIndex].addHoursToLastMintTimestamp; _lastMintBlockTimestamp += addHoursToLastMintTimestamp * secondsPerHour; emit logMintVmc(newTokenId);
9,063
38
// Event emitted when the reserves are added /
event ReservesAdded(address benefactor, uint addAmount, uint newTotalReserves);
event ReservesAdded(address benefactor, uint addAmount, uint newTotalReserves);
6,245
12
// Set the snapshot of NN total rewards /The function should be called by admin when upgrading function setNNRewardSum(uint128 sum) external onlyGovernance
// { // rewardSum = uint128(sum); // }
// { // rewardSum = uint128(sum); // }
12,819
6
// beneficiary of tokens (weis) after the sale ends
address private _beneficiary;
address private _beneficiary;
48,164
138
// convert 3Crv to HUSD
_before = tokenHUSD.balanceOf(address(this)); stableSwapHUSD.exchange(int128(1), int128(0), _amount, 1); _after = tokenHUSD.balanceOf(address(this)); _husd = _after.sub(_before);
_before = tokenHUSD.balanceOf(address(this)); stableSwapHUSD.exchange(int128(1), int128(0), _amount, 1); _after = tokenHUSD.balanceOf(address(this)); _husd = _after.sub(_before);
11,603