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
0
// L1DEX /
contract l1dex is SupervisedERC777Token { constructor () public SupervisedERC777Token("Decentralised Exchanges", "L1DEX") {} }
contract l1dex is SupervisedERC777Token { constructor () public SupervisedERC777Token("Decentralised Exchanges", "L1DEX") {} }
52,236
197
// Updates taxBurn
* Emits a {TaxBurnUpdate} event. * * Requirements: * * - auto burn feature must be enabled. * - total tax rate must be less than 100%. */ function setTaxBurn(uint8 taxBurn_, uint8 taxBurnDecimals_) public onlyOwner { require(_autoBurnEnabled, "Auto burn feature must be enabled. Try the EnableAutoBurn function."); require(taxBurn_ + _taxReward + _taxLiquify < 100, "Tax fee too high."); uint8 previousTax = _taxBurn; uint8 previousDecimals = _taxBurnDecimals; _taxBurn = taxBurn_; _taxBurnDecimals = taxBurnDecimals_; emit TaxBurnUpdate(previousTax, previousDecimals, taxBurn_, taxBurnDecimals_); }
* Emits a {TaxBurnUpdate} event. * * Requirements: * * - auto burn feature must be enabled. * - total tax rate must be less than 100%. */ function setTaxBurn(uint8 taxBurn_, uint8 taxBurnDecimals_) public onlyOwner { require(_autoBurnEnabled, "Auto burn feature must be enabled. Try the EnableAutoBurn function."); require(taxBurn_ + _taxReward + _taxLiquify < 100, "Tax fee too high."); uint8 previousTax = _taxBurn; uint8 previousDecimals = _taxBurnDecimals; _taxBurn = taxBurn_; _taxBurnDecimals = taxBurnDecimals_; emit TaxBurnUpdate(previousTax, previousDecimals, taxBurn_, taxBurnDecimals_); }
25,280
55
// Bird's BDelegation Storage/
contract BDelegationStorage { /** * @notice Implementation address for this contract */ address public implementation; }
contract BDelegationStorage { /** * @notice Implementation address for this contract */ address public implementation; }
18,881
7
// Returns bank node staking pool upBeacon contract/ return upBeaconBankNodeStakingPool bank node staking pool upBeacon contract
function upBeaconBankNodeStakingPool() external view returns (UpgradeableBeacon);
function upBeaconBankNodeStakingPool() external view returns (UpgradeableBeacon);
9,237
8
// Add a proposal _content content of proposal /
function addProposal(string memory _content) external { require(currentStatus == WorkflowStatus.ProposalsRegistrationStarted, "Not ProposalsRegistrationStarted Status"); require(voters[msg.sender].isRegistered, "Voter not registered"); require(voters[msg.sender].isAbleToPropose, "Voter not proposer"); require(!voters[msg.sender].hasProposed, "Voter has already proposed"); proposals.push(Proposal(_content, 0, msg.sender, true)); voters[msg.sender].hasProposed = true; uint proposalId = proposals.length-1; emit ProposalRegistered(proposalId, _content, msg.sender, sessionId); }
function addProposal(string memory _content) external { require(currentStatus == WorkflowStatus.ProposalsRegistrationStarted, "Not ProposalsRegistrationStarted Status"); require(voters[msg.sender].isRegistered, "Voter not registered"); require(voters[msg.sender].isAbleToPropose, "Voter not proposer"); require(!voters[msg.sender].hasProposed, "Voter has already proposed"); proposals.push(Proposal(_content, 0, msg.sender, true)); voters[msg.sender].hasProposed = true; uint proposalId = proposals.length-1; emit ProposalRegistered(proposalId, _content, msg.sender, sessionId); }
43,055
13
// returns earnable ICE for "amount" of ICE vested for "duration" seconds /
function getIceByVestingDuration(uint256 amount, uint256 duration, bool withDiscount) public view returns (uint256) { uint256 _minRedeemDuration = withDiscount ? minRedeemDurationDiscounted : minRedeemDuration; uint256 _maxRedeemDuration = withDiscount ? maxRedeemDurationDiscounted : maxRedeemDuration; if (duration < _minRedeemDuration) { return 0; } // capped to _maxRedeemDuration if (duration >= _maxRedeemDuration) { duration = _maxRedeemDuration; } // calculate APR for "duration" seconds & using 1 year = 360 days return amount.mul(redeemIceApr).mul(duration).div(360 days).div(1000); }
function getIceByVestingDuration(uint256 amount, uint256 duration, bool withDiscount) public view returns (uint256) { uint256 _minRedeemDuration = withDiscount ? minRedeemDurationDiscounted : minRedeemDuration; uint256 _maxRedeemDuration = withDiscount ? maxRedeemDurationDiscounted : maxRedeemDuration; if (duration < _minRedeemDuration) { return 0; } // capped to _maxRedeemDuration if (duration >= _maxRedeemDuration) { duration = _maxRedeemDuration; } // calculate APR for "duration" seconds & using 1 year = 360 days return amount.mul(redeemIceApr).mul(duration).div(360 days).div(1000); }
33,556
304
// Award from airdrop _id Airdrop ids _recipients Recepients of award _amount0s The karma amount _amount1s The currency amount _proofs Merkle proofs _proofLengths Merkle proof lengths /
function awardToMany(uint _id, address[] _recipients, uint[] _amount0s, uint[] _amount1s, bytes _proofs, uint[] _proofLengths) public { uint marker = 32; for (uint i = 0; i < _recipients.length; i++) { address recipient = _recipients[i]; if( airdrops[_id].awarded[recipient] ) continue; bytes32[] memory proof = extractProof(_proofs, marker, _proofLengths[i]); marker += _proofLengths[i]*32; bytes32 hash = keccak256(abi.encodePacked(recipient, _amount0s[i], _amount1s[i])); if( !validate(airdrops[_id].root, proof, hash) ) continue; airdrops[_id].awarded[recipient] = true; tokenManager0.mint(recipient, _amount0s[i]); tokenManager1.mint(recipient, _amount1s[i]); emit Award(_id, recipient, _amount0s[i], _amount1s[i]); } }
function awardToMany(uint _id, address[] _recipients, uint[] _amount0s, uint[] _amount1s, bytes _proofs, uint[] _proofLengths) public { uint marker = 32; for (uint i = 0; i < _recipients.length; i++) { address recipient = _recipients[i]; if( airdrops[_id].awarded[recipient] ) continue; bytes32[] memory proof = extractProof(_proofs, marker, _proofLengths[i]); marker += _proofLengths[i]*32; bytes32 hash = keccak256(abi.encodePacked(recipient, _amount0s[i], _amount1s[i])); if( !validate(airdrops[_id].root, proof, hash) ) continue; airdrops[_id].awarded[recipient] = true; tokenManager0.mint(recipient, _amount0s[i]); tokenManager1.mint(recipient, _amount1s[i]); emit Award(_id, recipient, _amount0s[i], _amount1s[i]); } }
41,162
107
// uint256 eathValue = msg.value.div(1e18);
uint256 amountToBuy = (msg.value.div(tokenPrice)).mul(1e18); uint256 vendorBalance = yourToken.balanceOf(address(this)); require(vendorBalance >= amountToBuy, "Vendor contract has not enough tokens in its balance"); (bool sent) = yourToken.transfer(msg.sender, amountToBuy); require(sent, "Failed to transfer token to user"); emit BuyTokens(msg.sender, msg.value, amountToBuy); return amountToBuy;
uint256 amountToBuy = (msg.value.div(tokenPrice)).mul(1e18); uint256 vendorBalance = yourToken.balanceOf(address(this)); require(vendorBalance >= amountToBuy, "Vendor contract has not enough tokens in its balance"); (bool sent) = yourToken.transfer(msg.sender, amountToBuy); require(sent, "Failed to transfer token to user"); emit BuyTokens(msg.sender, msg.value, amountToBuy); return amountToBuy;
16,617
81
// Get the next floor and set it
uint256 nextCollateralFloor = getNextCollateralFloor(); setFloor(nextCollateralFloor);
uint256 nextCollateralFloor = getNextCollateralFloor(); setFloor(nextCollateralFloor);
16,812
254
// ========== yearn V2 ========== /
function yDepositUSDC(uint256 USDC_amount) public onlyByOwnerOrGovernance { require(allow_yearn, 'yearn strategy is currently off'); collateral_token.approve(address(yUSDC_V2), USDC_amount); yUSDC_V2.deposit(USDC_amount); }
function yDepositUSDC(uint256 USDC_amount) public onlyByOwnerOrGovernance { require(allow_yearn, 'yearn strategy is currently off'); collateral_token.approve(address(yUSDC_V2), USDC_amount); yUSDC_V2.deposit(USDC_amount); }
22,185
165
// transfers tokens to contract and calcualtes amount sent with fees tokenAddress address of the token totalDeposited total tokens attempting to be sent tokenFee fee taken for lockingreturn total amount sent /
function _transferAndCalculateWithFee( address tokenAddress, uint totalDeposited, uint tokenFee
function _transferAndCalculateWithFee( address tokenAddress, uint totalDeposited, uint tokenFee
13,518
1
// โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—\/Synapse:Bridge address
ISynapseBridge public immutable synapseBridge;
ISynapseBridge public immutable synapseBridge;
16,521
32
// Transfer the balance from owner&39;s account to advisor&39;s account
function transferToAdvisors(address _to, uint256 _amount) public returns(bool success) { require( _to != 0x0); require(balances[msg.sender] >= _amount && _amount >= 0); // if this is a new advisor if(!isAdvisor(_to)) { addAdvisor(_to); advisorCount++ ; } balances[msg.sender] = (balances[msg.sender]).sub(_amount); balances[_to] = (balances[_to]).add(_amount); Transfer(msg.sender, _to, _amount); return true; }
function transferToAdvisors(address _to, uint256 _amount) public returns(bool success) { require( _to != 0x0); require(balances[msg.sender] >= _amount && _amount >= 0); // if this is a new advisor if(!isAdvisor(_to)) { addAdvisor(_to); advisorCount++ ; } balances[msg.sender] = (balances[msg.sender]).sub(_amount); balances[_to] = (balances[_to]).add(_amount); Transfer(msg.sender, _to, _amount); return true; }
35,039
986
// Calculate repay amount (_amount + (2 wei)) Approve transfer from
uint256 repayAmount = _getRepaymentAmountInternal(_ethAmount); ERC20(WETH_ADDR).approve(SOLO_MARGIN_ADDRESS, repayAmount); Actions.ActionArgs[] memory operations = new Actions.ActionArgs[](3); operations[0] = _getWithdrawAction(marketId, _ethAmount, _receiver); operations[1] = _getCallAction( _encodedData, _receiver );
uint256 repayAmount = _getRepaymentAmountInternal(_ethAmount); ERC20(WETH_ADDR).approve(SOLO_MARGIN_ADDRESS, repayAmount); Actions.ActionArgs[] memory operations = new Actions.ActionArgs[](3); operations[0] = _getWithdrawAction(marketId, _ethAmount, _receiver); operations[1] = _getCallAction( _encodedData, _receiver );
55,177
0
// protoId is a precursor hash to a cloneId used to identify tokenId/erc20 pairs
mapping(uint256 => uint256) public protoIdToIndexHead;
mapping(uint256 => uint256) public protoIdToIndexHead;
5,779
19
// IArbitrable Arbitrable interface. When developing arbitrable contracts, we need to: -Define the action taken when a ruling is received by the contract. We should do so in executeRuling. -Allow dispute creation. For this a function must: -Call arbitrator.createDispute.value(_fee)(_choices,_extraData); -Create the event Dispute(_arbitrator,_disputeID,_rulingOptions); /
interface IArbitrable { /** @dev To be emmited when meta-evidence is submitted. * @param _metaEvidenceID Unique identifier of meta-evidence. * @param _evidence A link to the meta-evidence JSON. */ event MetaEvidence(uint indexed _metaEvidenceID, string _evidence); /** @dev To be emmited when a dispute is created to link the correct meta-evidence to the disputeID * @param _arbitrator The arbitrator of the contract. * @param _disputeID ID of the dispute in the Arbitrator contract. * @param _metaEvidenceID Unique identifier of meta-evidence. * @param _evidenceGroupID Unique identifier of the evidence group that is linked to this dispute. */ event Dispute(Arbitrator indexed _arbitrator, uint indexed _disputeID, uint _metaEvidenceID, uint _evidenceGroupID); /** @dev To be raised when evidence are submitted. Should point to the ressource (evidences are not to be stored on chain due to gas considerations). * @param _arbitrator The arbitrator of the contract. * @param _evidenceGroupID Unique identifier of the evidence group the evidence belongs to. * @param _party The address of the party submiting the evidence. Note that 0x0 refers to evidence not submitted by any party. * @param _evidence A URI to the evidence JSON file whose name should be its keccak256 hash followed by .json. */ event Evidence(Arbitrator indexed _arbitrator, uint indexed _evidenceGroupID, address indexed _party, string _evidence); /** @dev To be raised when a ruling is given. * @param _arbitrator The arbitrator giving the ruling. * @param _disputeID ID of the dispute in the Arbitrator contract. * @param _ruling The ruling which was given. */ event Ruling(Arbitrator indexed _arbitrator, uint indexed _disputeID, uint _ruling); /** @dev Give a ruling for a dispute. Must be called by the arbitrator. * The purpose of this function is to ensure that the address calling it has the right to rule on the contract. * @param _disputeID ID of the dispute in the Arbitrator contract. * @param _ruling Ruling given by the arbitrator. Note that 0 is reserved for "Not able/wanting to make a decision". */ function rule(uint _disputeID, uint _ruling) public; }
interface IArbitrable { /** @dev To be emmited when meta-evidence is submitted. * @param _metaEvidenceID Unique identifier of meta-evidence. * @param _evidence A link to the meta-evidence JSON. */ event MetaEvidence(uint indexed _metaEvidenceID, string _evidence); /** @dev To be emmited when a dispute is created to link the correct meta-evidence to the disputeID * @param _arbitrator The arbitrator of the contract. * @param _disputeID ID of the dispute in the Arbitrator contract. * @param _metaEvidenceID Unique identifier of meta-evidence. * @param _evidenceGroupID Unique identifier of the evidence group that is linked to this dispute. */ event Dispute(Arbitrator indexed _arbitrator, uint indexed _disputeID, uint _metaEvidenceID, uint _evidenceGroupID); /** @dev To be raised when evidence are submitted. Should point to the ressource (evidences are not to be stored on chain due to gas considerations). * @param _arbitrator The arbitrator of the contract. * @param _evidenceGroupID Unique identifier of the evidence group the evidence belongs to. * @param _party The address of the party submiting the evidence. Note that 0x0 refers to evidence not submitted by any party. * @param _evidence A URI to the evidence JSON file whose name should be its keccak256 hash followed by .json. */ event Evidence(Arbitrator indexed _arbitrator, uint indexed _evidenceGroupID, address indexed _party, string _evidence); /** @dev To be raised when a ruling is given. * @param _arbitrator The arbitrator giving the ruling. * @param _disputeID ID of the dispute in the Arbitrator contract. * @param _ruling The ruling which was given. */ event Ruling(Arbitrator indexed _arbitrator, uint indexed _disputeID, uint _ruling); /** @dev Give a ruling for a dispute. Must be called by the arbitrator. * The purpose of this function is to ensure that the address calling it has the right to rule on the contract. * @param _disputeID ID of the dispute in the Arbitrator contract. * @param _ruling Ruling given by the arbitrator. Note that 0 is reserved for "Not able/wanting to make a decision". */ function rule(uint _disputeID, uint _ruling) public; }
10,365
236
// Handle the different scenarios that may arise when trading currencies with or without the PureChainlinkPrice set. outlined here: https:sips.synthetix.io/sips/sip-198/computation-methodology-in-atomic-pricing
if (usePureChainlinkPriceForSource) { sourceRate = systemSourceRate; } else {
if (usePureChainlinkPriceForSource) { sourceRate = systemSourceRate; } else {
11,870
15
// Convert Tokens to ETH && transfers ETH to recipient. User specifies exact input && minimum output. tokens_sold Amount of Tokens sold. min_eth Minimum ETH purchased. deadline Time after which this transaction can no longer be executed. recipient The address that receives output ETH.returnAmount of ETH bought. /
function tokenToEthTransferInput(uint256 tokens_sold, uint256 min_eth, uint256 deadline, address payable recipient) public returns (uint256) { require(recipient != address(this) && recipient != address(0)); return tokenToEthInput(tokens_sold, min_eth, deadline, msg.sender, recipient); }
function tokenToEthTransferInput(uint256 tokens_sold, uint256 min_eth, uint256 deadline, address payable recipient) public returns (uint256) { require(recipient != address(this) && recipient != address(0)); return tokenToEthInput(tokens_sold, min_eth, deadline, msg.sender, recipient); }
7,756
152
// Calculate pure call option price and N(d1) by black-scholes formula. spotPrice is a oracle price. strikePrice Strike price of call option volatilityE8 is a oracle volatility. untilMaturity Remaining period of target bond in second /
) public pure returns (uint256 price, int256 nd1E8) { require(spotPrice > 0 && spotPrice < 10**13, "oracle price should be between 0 and 10^13"); require( volatilityE8 > 0 && volatilityE8 < 10 * 10**8, "oracle volatility should be between 0% and 1000%" ); require( untilMaturity > 0 && untilMaturity < 31536000, "the bond should not have expired and less than 1 year" ); require( strikePrice > 0 && strikePrice < 10**13, "strike price should be between 0 and 10^13" ); int256 spotPerStrikeE4 = (spotPrice * 10**4) / strikePrice; int256 sigE8 = (volatilityE8 * (_sqrt(untilMaturity)) * (10**8)) / SQRT_YEAR_E8; int256 logSigE4 = _logTaylor(spotPerStrikeE4); int256 d1E4 = ((logSigE4 * 10**8) / sigE8) + (sigE8 / (2 * 10**4)); nd1E8 = _calcPnorm(d1E4); int256 d2E4 = d1E4 - (sigE8 / 10**4); int256 nd2E8 = _calcPnorm(d2E4); price = uint256(_calcLbtPrice(spotPrice, strikePrice, nd1E8, nd2E8)); }
) public pure returns (uint256 price, int256 nd1E8) { require(spotPrice > 0 && spotPrice < 10**13, "oracle price should be between 0 and 10^13"); require( volatilityE8 > 0 && volatilityE8 < 10 * 10**8, "oracle volatility should be between 0% and 1000%" ); require( untilMaturity > 0 && untilMaturity < 31536000, "the bond should not have expired and less than 1 year" ); require( strikePrice > 0 && strikePrice < 10**13, "strike price should be between 0 and 10^13" ); int256 spotPerStrikeE4 = (spotPrice * 10**4) / strikePrice; int256 sigE8 = (volatilityE8 * (_sqrt(untilMaturity)) * (10**8)) / SQRT_YEAR_E8; int256 logSigE4 = _logTaylor(spotPerStrikeE4); int256 d1E4 = ((logSigE4 * 10**8) / sigE8) + (sigE8 / (2 * 10**4)); nd1E8 = _calcPnorm(d1E4); int256 d2E4 = d1E4 - (sigE8 / 10**4); int256 nd2E8 = _calcPnorm(d2E4); price = uint256(_calcLbtPrice(spotPrice, strikePrice, nd1E8, nd2E8)); }
31,402
7
// Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), Reverts when dividing by zero. Counterpart to Solidity's `%` operator. This function uses a `revert` opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas). Requirements: - The divisor cannot be zero./
function mod(uint32 a, uint32 b) internal pure returns (uint32) { require(b != 0, "SafeMath: modulo by zero"); return a % b; }
function mod(uint32 a, uint32 b) internal pure returns (uint32) { require(b != 0, "SafeMath: modulo by zero"); return a % b; }
5,051
259
// Qbist /
contract Qbist is ERC721, Ownable { constructor (string memory name, string memory symbol) public ERC721(name, symbol) { } function exists(uint256 tokenId) public view returns (bool) { return _exists(tokenId); } function setTokenURI(uint256 tokenId, string memory uri) public onlyOwner { _setTokenURI(tokenId, uri); } function setBaseURI(string memory baseURI) public onlyOwner { _setBaseURI(baseURI); } function mint(address to, uint256 tokenId) public onlyOwner { _mint(to, tokenId); } function safeMint(address to, uint256 tokenId) public onlyOwner { _safeMint(to, tokenId); } function safeMint(address to, uint256 tokenId, bytes memory _data) public onlyOwner { _safeMint(to, tokenId, _data); } function burn(uint256 tokenId) public onlyOwner { _burn(tokenId); } function contractURI() public view returns (string memory) { return "https://gateway.ipfs.io/ipfs/QmbeNfAim5LyAEVKme3PDJ1FEEeJ9BK5z4Ha2RW1rcWYvh"; } }
contract Qbist is ERC721, Ownable { constructor (string memory name, string memory symbol) public ERC721(name, symbol) { } function exists(uint256 tokenId) public view returns (bool) { return _exists(tokenId); } function setTokenURI(uint256 tokenId, string memory uri) public onlyOwner { _setTokenURI(tokenId, uri); } function setBaseURI(string memory baseURI) public onlyOwner { _setBaseURI(baseURI); } function mint(address to, uint256 tokenId) public onlyOwner { _mint(to, tokenId); } function safeMint(address to, uint256 tokenId) public onlyOwner { _safeMint(to, tokenId); } function safeMint(address to, uint256 tokenId, bytes memory _data) public onlyOwner { _safeMint(to, tokenId, _data); } function burn(uint256 tokenId) public onlyOwner { _burn(tokenId); } function contractURI() public view returns (string memory) { return "https://gateway.ipfs.io/ipfs/QmbeNfAim5LyAEVKme3PDJ1FEEeJ9BK5z4Ha2RW1rcWYvh"; } }
21,931
19
// Gets the keeper registry address /
function getKeeperAddress() external view returns (address keeperAddress) { return KeeperAddress; }
function getKeeperAddress() external view returns (address keeperAddress) { return KeeperAddress; }
26,946
8
// Algebra pool deployer/Is used by AlgebraFactory to deploy pools/Version: Algebra V1.9
contract AlgebraPoolDeployer is IAlgebraPoolDeployer { struct Parameters { address dataStorage; address factory; address token0; address token1; } /// @inheritdoc IAlgebraPoolDeployer Parameters public override parameters; address private factory; address private owner; modifier onlyFactory() { require(msg.sender == factory); _; } modifier onlyOwner() { require(msg.sender == owner); _; } constructor() { owner = msg.sender; } /// @inheritdoc IAlgebraPoolDeployer function setFactory(address _factory) external override onlyOwner { require(_factory != address(0)); require(factory == address(0)); emit Factory(_factory); factory = _factory; } /// @inheritdoc IAlgebraPoolDeployer function deploy( address dataStorage, address _factory, address token0, address token1 ) external override onlyFactory returns (address pool) { parameters = Parameters({dataStorage: dataStorage, factory: _factory, token0: token0, token1: token1}); pool = address(new AlgebraPool{salt: keccak256(abi.encode(token0, token1))}()); } }
contract AlgebraPoolDeployer is IAlgebraPoolDeployer { struct Parameters { address dataStorage; address factory; address token0; address token1; } /// @inheritdoc IAlgebraPoolDeployer Parameters public override parameters; address private factory; address private owner; modifier onlyFactory() { require(msg.sender == factory); _; } modifier onlyOwner() { require(msg.sender == owner); _; } constructor() { owner = msg.sender; } /// @inheritdoc IAlgebraPoolDeployer function setFactory(address _factory) external override onlyOwner { require(_factory != address(0)); require(factory == address(0)); emit Factory(_factory); factory = _factory; } /// @inheritdoc IAlgebraPoolDeployer function deploy( address dataStorage, address _factory, address token0, address token1 ) external override onlyFactory returns (address pool) { parameters = Parameters({dataStorage: dataStorage, factory: _factory, token0: token0, token1: token1}); pool = address(new AlgebraPool{salt: keccak256(abi.encode(token0, token1))}()); } }
14,746
22
// Gets part of delayed rewards that have become available. /
function getClaimableDelayed(address account) external view returns (uint256);
function getClaimableDelayed(address account) external view returns (uint256);
37,336
4
// Balance = pool's balance + pool's token controller contract balance
function balance() public view returns (uint256) { return token.balanceOf(address(this)).add( IController(controller).balanceOf(address(token)) ); }
function balance() public view returns (uint256) { return token.balanceOf(address(this)).add( IController(controller).balanceOf(address(token)) ); }
29,600
34
// za = c/ฮผ(normalizedSharesReservesa) The โ€œpow(x, y, z)โ€ function not only calculates x^(y/z) but also normalizes the result to fit into 64.64 fixed point number, i.e. it actually calculates: x^(y/z)(2^63)^(1 - y/z)
uint256 za = c.div(mu).mulu(uint128(mu.mulu(sharesReserves)).pow(a, ONE)); require(za <= MAX, "YieldMath: Rate overflow (za)");
uint256 za = c.div(mu).mulu(uint128(mu.mulu(sharesReserves)).pow(a, ONE)); require(za <= MAX, "YieldMath: Rate overflow (za)");
29,279
5
// id object
attributes = string( abi.encodePacked( attributes, '{"trait_type":"id",', '"value": "', _stats.id, '"},'
attributes = string( abi.encodePacked( attributes, '{"trait_type":"id",', '"value": "', _stats.id, '"},'
19,022
425
// Requires that there is a committed draw that has not been rewarded. /
modifier requireCommittedNoReward() { require(currentCommittedDrawId() > 0, "Pool/committed"); require(!currentCommittedDrawHasBeenRewarded(), "Pool/already"); _; }
modifier requireCommittedNoReward() { require(currentCommittedDrawId() > 0, "Pool/committed"); require(!currentCommittedDrawHasBeenRewarded(), "Pool/already"); _; }
55,326
25
// Allows the sender to claim the tokens he is allowed to withdraw/
function claimTokens() public { require(getWithdrawableAmount(msg.sender) != 0); uint256 amount = getWithdrawableAmount(msg.sender); withdrawn[msg.sender] = withdrawn[msg.sender].add(amount); _deliverTokens(msg.sender, amount); }
function claimTokens() public { require(getWithdrawableAmount(msg.sender) != 0); uint256 amount = getWithdrawableAmount(msg.sender); withdrawn[msg.sender] = withdrawn[msg.sender].add(amount); _deliverTokens(msg.sender, amount); }
17,665
106
// unlock k block for Voting Pool
uint256 constant unlockKBlocksV = 1800;
uint256 constant unlockKBlocksV = 1800;
1,627
10
// start the presale (only for MANAGER_ROLE) /
function start() external virtual onlyRole(MANAGER_ROLE) { require(_presaleStartedAt == 0, "Presale is started"); // solhint-disable-next-line not-rely-on-time _presaleStartedAt = block.timestamp; _presaleFinishedAt = 0; emit PresaleStarted(msg.sender); }
function start() external virtual onlyRole(MANAGER_ROLE) { require(_presaleStartedAt == 0, "Presale is started"); // solhint-disable-next-line not-rely-on-time _presaleStartedAt = block.timestamp; _presaleFinishedAt = 0; emit PresaleStarted(msg.sender); }
5,693
110
// Burns a specific ERC721 token. tokenId uint256 id of the ERC721 token to be burned. /
function burn(uint256 tokenId) public { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721Burnable: caller is not owner nor approved"); _burn(tokenId); }
function burn(uint256 tokenId) public { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721Burnable: caller is not owner nor approved"); _burn(tokenId); }
21,406
13
// Function to match the orders in the orderbook /
uint64 maxbid_id=BidOrderBook.getMaximum(); if (maxbid_id==0){ revert(); }
uint64 maxbid_id=BidOrderBook.getMaximum(); if (maxbid_id==0){ revert(); }
15,556
2
// Tiempo que durarรก la votaciรณn.
votingEndDate = now + 15 days; address[] memory emptyArray;
votingEndDate = now + 15 days; address[] memory emptyArray;
42,619
11
// Return all addresses where rawPermissionMask bit for permissionId is set to 1./permissionId Id of the permission to check./ return A list of dirty addresses.
function addressesByPermission(uint8 permissionId) external view returns (address[] memory);
function addressesByPermission(uint8 permissionId) external view returns (address[] memory);
17,317
1
// Use forge-std Vm logic
Vm public constant vm = Vm(HEVM_ADDRESS);
Vm public constant vm = Vm(HEVM_ADDRESS);
28,472
301
// We'll need to keep track of left and right siblings.
bytes32 leftSibling; bytes32 rightSibling;
bytes32 leftSibling; bytes32 rightSibling;
63,377
21
// Returns symbol of token/
function symbol() external pure returns(string memory){ return _symbol; }
function symbol() external pure returns(string memory){ return _symbol; }
8,685
18
// Validate token is the same
require( order.token == orders[0].token, "Order token mismatch" );
require( order.token == orders[0].token, "Order token mismatch" );
18,806
73
// Return bBadger to Badger Governance to revoke escrow deal
function revoke() external { require(msg.sender == badgerGovernance, "onlyBadgerGovernance"); uint256 bBadgerBalance = IERC20(bBadger).balanceOf(address(this)); IERC20(bBadger).safeTransfer(badgerGovernance, bBadgerBalance); }
function revoke() external { require(msg.sender == badgerGovernance, "onlyBadgerGovernance"); uint256 bBadgerBalance = IERC20(bBadger).balanceOf(address(this)); IERC20(bBadger).safeTransfer(badgerGovernance, bBadgerBalance); }
9,541
23
// CHECKS // Calculate first order hash. // Check first order validity. // Calculate second order hash. // Check second order validity. // Prevent self-matching (possibly unnecessary, but safer). // Calculate signatures (must be awkwardly decoded here due to stack size constraints). // Check first order authorization. // Check second order authorization. / Price will transfer to money transfer contract
41,337
25
// Token definitionDefine token paramters including ERC20 ones/
contract ERC20Token is ERC20TokenInterface, admined { //Standard definition of a ERC20Token using SafeMath for uint256; uint256 public totalSupply; mapping (address => uint256) balances; //A mapping of all balances per address mapping (address => mapping (address => uint256)) allowed; //A mapping of all allowances mapping (address => bool) frozen; //A mapping of frozen accounts /** * @dev Get the balance of an specified address. * @param _owner The address to be query. */ function balanceOf(address _owner) public constant returns (uint256 value) { return balances[_owner]; } /** * @dev transfer token to a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) transferLock public returns (bool success) { require(_to != address(0)); //If you dont want that people destroy token require(frozen[msg.sender]==false); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } /** * @dev transfer token from an address to another specified address using allowance * @param _from The address where token comes. * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transferFrom(address _from, address _to, uint256 _value) transferLock public returns (bool success) { require(_to != address(0)); //If you dont want that people destroy token require(frozen[_from]==false); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Assign allowance to an specified address to use the owner balance * @param _spender The address to be allowed to spend. * @param _value The amount to be allowed. */ function approve(address _spender, uint256 _value) public returns (bool success) { require((_value == 0) || (allowed[msg.sender][_spender] == 0)); //exploit mitigation allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Get the allowance of an specified address to use another address balance. * @param _owner The address of the owner of the tokens. * @param _spender The address of the allowed spender. */ function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } /** * @dev Mint token to an specified address. * @param _target The address of the receiver of the tokens. * @param _mintedAmount amount to mint. */ function mintToken(address _target, uint256 _mintedAmount) onlyAdmin supplyLock public { balances[_target] = SafeMath.add(balances[_target], _mintedAmount); totalSupply = SafeMath.add(totalSupply, _mintedAmount); emit Transfer(0, this, _mintedAmount); emit Transfer(this, _target, _mintedAmount); } /** * @dev Burn token of an specified address. * @param _target The address of the holder of the tokens. * @param _burnedAmount amount to burn. */ function burnToken(address _target, uint256 _burnedAmount) onlyAdmin supplyLock public { balances[_target] = SafeMath.sub(balances[_target], _burnedAmount); totalSupply = SafeMath.sub(totalSupply, _burnedAmount); emit Burned(_target, _burnedAmount); } /** * @dev Frozen account. * @param _target The address to being frozen. * @param _flag The status of the frozen */ function setFrozen(address _target,bool _flag) onlyAdmin public { frozen[_target]=_flag; emit FrozenStatus(_target,_flag); } /** * @dev Log Events */ event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Burned(address indexed _target, uint256 _value); event FrozenStatus(address _target,bool _flag); }
contract ERC20Token is ERC20TokenInterface, admined { //Standard definition of a ERC20Token using SafeMath for uint256; uint256 public totalSupply; mapping (address => uint256) balances; //A mapping of all balances per address mapping (address => mapping (address => uint256)) allowed; //A mapping of all allowances mapping (address => bool) frozen; //A mapping of frozen accounts /** * @dev Get the balance of an specified address. * @param _owner The address to be query. */ function balanceOf(address _owner) public constant returns (uint256 value) { return balances[_owner]; } /** * @dev transfer token to a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) transferLock public returns (bool success) { require(_to != address(0)); //If you dont want that people destroy token require(frozen[msg.sender]==false); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } /** * @dev transfer token from an address to another specified address using allowance * @param _from The address where token comes. * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transferFrom(address _from, address _to, uint256 _value) transferLock public returns (bool success) { require(_to != address(0)); //If you dont want that people destroy token require(frozen[_from]==false); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Assign allowance to an specified address to use the owner balance * @param _spender The address to be allowed to spend. * @param _value The amount to be allowed. */ function approve(address _spender, uint256 _value) public returns (bool success) { require((_value == 0) || (allowed[msg.sender][_spender] == 0)); //exploit mitigation allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Get the allowance of an specified address to use another address balance. * @param _owner The address of the owner of the tokens. * @param _spender The address of the allowed spender. */ function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } /** * @dev Mint token to an specified address. * @param _target The address of the receiver of the tokens. * @param _mintedAmount amount to mint. */ function mintToken(address _target, uint256 _mintedAmount) onlyAdmin supplyLock public { balances[_target] = SafeMath.add(balances[_target], _mintedAmount); totalSupply = SafeMath.add(totalSupply, _mintedAmount); emit Transfer(0, this, _mintedAmount); emit Transfer(this, _target, _mintedAmount); } /** * @dev Burn token of an specified address. * @param _target The address of the holder of the tokens. * @param _burnedAmount amount to burn. */ function burnToken(address _target, uint256 _burnedAmount) onlyAdmin supplyLock public { balances[_target] = SafeMath.sub(balances[_target], _burnedAmount); totalSupply = SafeMath.sub(totalSupply, _burnedAmount); emit Burned(_target, _burnedAmount); } /** * @dev Frozen account. * @param _target The address to being frozen. * @param _flag The status of the frozen */ function setFrozen(address _target,bool _flag) onlyAdmin public { frozen[_target]=_flag; emit FrozenStatus(_target,_flag); } /** * @dev Log Events */ event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Burned(address indexed _target, uint256 _value); event FrozenStatus(address _target,bool _flag); }
14,634
16
// Return the cosine of a value, specified in radians scaled by 1e18 This is identical to the sin() method, and just computes the value by delegating to thesin() method using the identity cos(x) = sin(x + pi/2) Overflow when `angle + PI_OVER_TWO > type(uint256).max` is ok, results are still accurate _angle Angle to convertreturn Result scaled by 1e18 /
function cos(uint256 _angle) internal pure returns (int256) { unchecked { return sin(_angle + PI_OVER_TWO); } }
function cos(uint256 _angle) internal pure returns (int256) { unchecked { return sin(_angle + PI_OVER_TWO); } }
26,039
18
// Did mSpellStaking receive any token
if (_rewardBalance == lastRewardBalance || _totalSpell == 0) { return; }
if (_rewardBalance == lastRewardBalance || _totalSpell == 0) { return; }
71,594
4
// change the registry address _regAddressaddress of the registry /
function setRegistryAddress(string memory _regAddress) external onlyAdmin { registryAddress = _regAddress; }
function setRegistryAddress(string memory _regAddress) external onlyAdmin { registryAddress = _regAddress; }
33,672
180
// Receive Ether
event Received(address from, uint amount);
event Received(address from, uint amount);
10,125
83
// This contract now has the funds requested. Your logic goes here.
opVars memory vars;
opVars memory vars;
57,555
10
// withdraw
uint public balanceReceived;
uint public balanceReceived;
16,817
17
// The number of halvings since inception
uint256 public halvingCounter;
uint256 public halvingCounter;
17,791
18
// Students can dropout after the course starts but it will get logged and stake will be sent to Peace Antz Council multisig.
function dropOut() external payable onlyRole(STUDENT){ require(courseStatus == true, "Course has not started yet, feel free to simply withdraw :)"); require(courseCompleted[msg.sender] == false, "You have completed the course already!"); (bool success, ) = peaceAntzCouncil.call{value: studentStake}(""); require(success, "Failed to drop course :("); _revokeRole(STUDENT, msg.sender); factory.updateDropout(msg.sender, studentStake); emit DropOut(msg.sender); }
function dropOut() external payable onlyRole(STUDENT){ require(courseStatus == true, "Course has not started yet, feel free to simply withdraw :)"); require(courseCompleted[msg.sender] == false, "You have completed the course already!"); (bool success, ) = peaceAntzCouncil.call{value: studentStake}(""); require(success, "Failed to drop course :("); _revokeRole(STUDENT, msg.sender); factory.updateDropout(msg.sender, studentStake); emit DropOut(msg.sender); }
23,474
91
// Sets that the message sent to the AMB bridge has been fixed._messageId of the message sent to the bridge./
function setMessageFixed(bytes32 _messageId) internal { boolStorage[keccak256(abi.encodePacked("messageFixed", _messageId))] = true; }
function setMessageFixed(bytes32 _messageId) internal { boolStorage[keccak256(abi.encodePacked("messageFixed", _messageId))] = true; }
2,295
430
// TokenWhitelist stores a list of tokens used by the Consumer Contract Wallet, the Oracle, the TKN Holder and the TKN Licence Contract
contract TokenWhitelist is ENSResolvable, Controllable, Transferrable { using strings for *; using SafeMath for uint256; using BytesUtils for bytes; event UpdatedTokenRate(address _sender, address _token, uint _rate); event UpdatedTokenLoadable(address _sender, address _token, bool _loadable); event UpdatedTokenRedeemable(address _sender, address _token, bool _redeemable); event AddedToken(address _sender, address _token, string _symbol, uint _magnitude, bool _loadable, bool _redeemable); event RemovedToken(address _sender, address _token); event AddedMethodId(bytes4 _methodId); event RemovedMethodId(bytes4 _methodId); event AddedExclusiveMethod(address _token, bytes4 _methodId); event RemovedExclusiveMethod(address _token, bytes4 _methodId); event Claimed(address _to, address _asset, uint _amount); /// @dev these are the methods whitelisted by default in executeTransaction() for protected tokens bytes4 private constant _APPROVE = 0x095ea7b3; // keccak256(approve(address,uint256)) => 0x095ea7b3 bytes4 private constant _BURN = 0x42966c68; // keccak256(burn(uint256)) => 0x42966c68 bytes4 private constant _TRANSFER= 0xa9059cbb; // keccak256(transfer(address,uint256)) => 0xa9059cbb bytes4 private constant _TRANSFER_FROM = 0x23b872dd; // keccak256(transferFrom(address,address,uint256)) => 0x23b872dd struct Token { string symbol; // Token symbol uint magnitude; // 10^decimals uint rate; // Token exchange rate in wei bool available; // Flags if the token is available or not bool loadable; // Flags if token is loadable to the TokenCard bool redeemable; // Flags if token is redeemable in the TKN Holder contract uint lastUpdate; // Time of the last rate update } mapping(address => Token) private _tokenInfoMap; // @notice specifies whitelisted methodIds for protected tokens in wallet's excuteTranaction() e.g. keccak256(transfer(address,uint256)) => 0xa9059cbb mapping(bytes4 => bool) private _methodIdWhitelist; address[] private _tokenAddressArray; /// @notice keeping track of how many redeemable tokens are in the tokenWhitelist uint private _redeemableCounter; /// @notice Address of the stablecoin. address private _stablecoin; /// @notice is registered ENS node identifying the oracle contract. bytes32 private _oracleNode; /// @notice Constructor initializes ENSResolvable, and Controllable. /// @param _ens_ is the ENS registry address. /// @param _oracleNode_ is the ENS node of the Oracle. /// @param _controllerNode_ is our Controllers node. /// @param _stablecoinAddress_ is the address of the stablecoint used by the wallet for the card load limit. constructor(address _ens_, bytes32 _oracleNode_, bytes32 _controllerNode_, address _stablecoinAddress_) ENSResolvable(_ens_) Controllable(_controllerNode_) public { _oracleNode = _oracleNode_; _stablecoin = _stablecoinAddress_; //a priori ERC20 whitelisted methods _methodIdWhitelist[_APPROVE] = true; _methodIdWhitelist[_BURN] = true; _methodIdWhitelist[_TRANSFER] = true; _methodIdWhitelist[_TRANSFER_FROM] = true; } modifier onlyAdminOrOracle() { address oracleAddress = _ensResolve(_oracleNode); require (_isAdmin(msg.sender) || msg.sender == oracleAddress, "either oracle or admin"); _; } /// @notice Add ERC20 tokens to the list of whitelisted tokens. /// @param _tokens ERC20 token contract addresses. /// @param _symbols ERC20 token names. /// @param _magnitude 10 to the power of number of decimal places used by each ERC20 token. /// @param _loadable is a bool that states whether or not a token is loadable to the TokenCard. /// @param _redeemable is a bool that states whether or not a token is redeemable in the TKN Holder Contract. /// @param _lastUpdate is a unit representing an ISO datetime e.g. 20180913153211. function addTokens(address[] calldata _tokens, bytes32[] calldata _symbols, uint[] calldata _magnitude, bool[] calldata _loadable, bool[] calldata _redeemable, uint _lastUpdate) external onlyAdmin { // Require that all parameters have the same length. require(_tokens.length == _symbols.length && _tokens.length == _magnitude.length && _tokens.length == _loadable.length && _tokens.length == _loadable.length, "parameter lengths do not match"); // Add each token to the list of supported tokens. for (uint i = 0; i < _tokens.length; i++) { // Require that the token isn't already available. require(!_tokenInfoMap[_tokens[i]].available, "token already available"); // Store the intermediate values. string memory symbol = _symbols[i].toSliceB32().toString(); // Add the token to the token list. _tokenInfoMap[_tokens[i]] = Token({ symbol : symbol, magnitude : _magnitude[i], rate : 0, available : true, loadable : _loadable[i], redeemable: _redeemable[i], lastUpdate : _lastUpdate }); // Add the token address to the address list. _tokenAddressArray.push(_tokens[i]); //if the token is redeemable increase the redeemableCounter if (_redeemable[i]){ _redeemableCounter = _redeemableCounter.add(1); } // Emit token addition event. emit AddedToken(msg.sender, _tokens[i], symbol, _magnitude[i], _loadable[i], _redeemable[i]); } } /// @notice Remove ERC20 tokens from the whitelist of tokens. /// @param _tokens ERC20 token contract addresses. function removeTokens(address[] calldata _tokens) external onlyAdmin { // Delete each token object from the list of supported tokens based on the addresses provided. for (uint i = 0; i < _tokens.length; i++) { // Store the token address. address token = _tokens[i]; //token must be available, reverts on duplicates as well require(_tokenInfoMap[token].available, "token is not available"); //if the token is redeemable decrease the redeemableCounter if (_tokenInfoMap[token].redeemable){ _redeemableCounter = _redeemableCounter.sub(1); } // Delete the token object. delete _tokenInfoMap[token]; // Remove the token address from the address list. for (uint j = 0; j < _tokenAddressArray.length.sub(1); j++) { if (_tokenAddressArray[j] == token) { _tokenAddressArray[j] = _tokenAddressArray[_tokenAddressArray.length.sub(1)]; break; } } _tokenAddressArray.length--; // Emit token removal event. emit RemovedToken(msg.sender, token); } } /// @notice based on the method it returns the recipient address and amount/value, ERC20 specific. /// @param _data is the transaction payload. function getERC20RecipientAndAmount(address _token, bytes calldata _data) external view returns (address, uint) { // Require that there exist enough bytes for encoding at least a method signature + data in the transaction payload: // 4 (signature) + 32(address or uint256) require(_data.length >= 4 + 32, "not enough method-encoding bytes"); // Get the method signature bytes4 signature = _data._bytesToBytes4(0); // Check if method Id is supported require(isERC20MethodSupported(_token, signature), "unsupported method"); // returns the recipient's address and amount is the value to be transferred if (signature == _BURN) { // 4 (signature) + 32(uint256) return (_token, _data._bytesToUint256(4)); } else if (signature == _TRANSFER_FROM) { // 4 (signature) + 32(address) + 32(address) + 32(uint256) require(_data.length >= 4 + 32 + 32 + 32, "not enough data for transferFrom"); return ( _data._bytesToAddress(4 + 32 + 12), _data._bytesToUint256(4 + 32 + 32)); } else { //transfer or approve // 4 (signature) + 32(address) + 32(uint) require(_data.length >= 4 + 32 + 32, "not enough data for transfer/appprove"); return (_data._bytesToAddress(4 + 12), _data._bytesToUint256(4 + 32)); } } /// @notice Toggles whether or not a token is loadable or not. function setTokenLoadable(address _token, bool _loadable) external onlyAdmin { // Require that the token exists. require(_tokenInfoMap[_token].available, "token is not available"); // this sets the loadable flag to the value passed in _tokenInfoMap[_token].loadable = _loadable; emit UpdatedTokenLoadable(msg.sender, _token, _loadable); } /// @notice Toggles whether or not a token is redeemable or not. function setTokenRedeemable(address _token, bool _redeemable) external onlyAdmin { // Require that the token exists. require(_tokenInfoMap[_token].available, "token is not available"); // this sets the redeemable flag to the value passed in _tokenInfoMap[_token].redeemable = _redeemable; emit UpdatedTokenRedeemable(msg.sender, _token, _redeemable); } /// @notice Update ERC20 token exchange rate. /// @param _token ERC20 token contract address. /// @param _rate ERC20 token exchange rate in wei. /// @param _updateDate date for the token updates. This will be compared to when oracle updates are received. function updateTokenRate(address _token, uint _rate, uint _updateDate) external onlyAdminOrOracle { // Require that the token exists. require(_tokenInfoMap[_token].available, "token is not available"); // Update the token's rate. _tokenInfoMap[_token].rate = _rate; // Update the token's last update timestamp. _tokenInfoMap[_token].lastUpdate = _updateDate; // Emit the rate update event. emit UpdatedTokenRate(msg.sender, _token, _rate); } //// @notice Withdraw tokens from the smart contract to the specified account. function claim(address payable _to, address _asset, uint _amount) external onlyAdmin { _safeTransfer(_to, _asset, _amount); emit Claimed(_to, _asset, _amount); } /// @notice This returns all of the fields for a given token. /// @param _a is the address of a given token. /// @return string of the token's symbol. /// @return uint of the token's magnitude. /// @return uint of the token's exchange rate to ETH. /// @return bool whether the token is available. /// @return bool whether the token is loadable to the TokenCard. /// @return bool whether the token is redeemable to the TKN Holder Contract. /// @return uint of the lastUpdated time of the token's exchange rate. function getTokenInfo(address _a) external view returns (string memory, uint256, uint256, bool, bool, bool, uint256) { Token storage tokenInfo = _tokenInfoMap[_a]; return (tokenInfo.symbol, tokenInfo.magnitude, tokenInfo.rate, tokenInfo.available, tokenInfo.loadable, tokenInfo.redeemable, tokenInfo.lastUpdate); } /// @notice This returns all of the fields for our StableCoin. /// @return string of the token's symbol. /// @return uint of the token's magnitude. /// @return uint of the token's exchange rate to ETH. /// @return bool whether the token is available. /// @return bool whether the token is loadable to the TokenCard. /// @return bool whether the token is redeemable to the TKN Holder Contract. /// @return uint of the lastUpdated time of the token's exchange rate. function getStablecoinInfo() external view returns (string memory, uint256, uint256, bool, bool, bool, uint256) { Token storage stablecoinInfo = _tokenInfoMap[_stablecoin]; return (stablecoinInfo.symbol, stablecoinInfo.magnitude, stablecoinInfo.rate, stablecoinInfo.available, stablecoinInfo.loadable, stablecoinInfo.redeemable, stablecoinInfo.lastUpdate); } /// @notice This returns an array of all whitelisted token addresses. /// @return address[] of whitelisted tokens. function tokenAddressArray() external view returns (address[] memory) { return _tokenAddressArray; } /// @notice This returns an array of all redeemable token addresses. /// @return address[] of redeemable tokens. function redeemableTokens() external view returns (address[] memory) { address[] memory redeemableAddresses = new address[](_redeemableCounter); uint redeemableIndex = 0; for (uint i = 0; i < _tokenAddressArray.length; i++) { address token = _tokenAddressArray[i]; if (_tokenInfoMap[token].redeemable){ redeemableAddresses[redeemableIndex] = token; redeemableIndex += 1; } } return redeemableAddresses; } /// @notice This returns true if a method Id is supported for the specific token. /// @return true if _methodId is supported in general or just for the specific token. function isERC20MethodSupported(address _token, bytes4 _methodId) public view returns (bool) { require(_tokenInfoMap[_token].available, "non-existing token"); return (_methodIdWhitelist[_methodId]); } /// @notice This returns true if the method is supported for all protected tokens. /// @return true if _methodId is in the method whitelist. function isERC20MethodWhitelisted(bytes4 _methodId) external view returns (bool) { return (_methodIdWhitelist[_methodId]); } /// @notice This returns the number of redeemable tokens. /// @return current # of redeemables. function redeemableCounter() external view returns (uint) { return _redeemableCounter; } /// @notice This returns the address of our stablecoin of choice. /// @return the address of the stablecoin contract. function stablecoin() external view returns (address) { return _stablecoin; } /// @notice this returns the node hash of our Oracle. /// @return the oracle node registered in ENS. function oracleNode() external view returns (bytes32) { return _oracleNode; } }
contract TokenWhitelist is ENSResolvable, Controllable, Transferrable { using strings for *; using SafeMath for uint256; using BytesUtils for bytes; event UpdatedTokenRate(address _sender, address _token, uint _rate); event UpdatedTokenLoadable(address _sender, address _token, bool _loadable); event UpdatedTokenRedeemable(address _sender, address _token, bool _redeemable); event AddedToken(address _sender, address _token, string _symbol, uint _magnitude, bool _loadable, bool _redeemable); event RemovedToken(address _sender, address _token); event AddedMethodId(bytes4 _methodId); event RemovedMethodId(bytes4 _methodId); event AddedExclusiveMethod(address _token, bytes4 _methodId); event RemovedExclusiveMethod(address _token, bytes4 _methodId); event Claimed(address _to, address _asset, uint _amount); /// @dev these are the methods whitelisted by default in executeTransaction() for protected tokens bytes4 private constant _APPROVE = 0x095ea7b3; // keccak256(approve(address,uint256)) => 0x095ea7b3 bytes4 private constant _BURN = 0x42966c68; // keccak256(burn(uint256)) => 0x42966c68 bytes4 private constant _TRANSFER= 0xa9059cbb; // keccak256(transfer(address,uint256)) => 0xa9059cbb bytes4 private constant _TRANSFER_FROM = 0x23b872dd; // keccak256(transferFrom(address,address,uint256)) => 0x23b872dd struct Token { string symbol; // Token symbol uint magnitude; // 10^decimals uint rate; // Token exchange rate in wei bool available; // Flags if the token is available or not bool loadable; // Flags if token is loadable to the TokenCard bool redeemable; // Flags if token is redeemable in the TKN Holder contract uint lastUpdate; // Time of the last rate update } mapping(address => Token) private _tokenInfoMap; // @notice specifies whitelisted methodIds for protected tokens in wallet's excuteTranaction() e.g. keccak256(transfer(address,uint256)) => 0xa9059cbb mapping(bytes4 => bool) private _methodIdWhitelist; address[] private _tokenAddressArray; /// @notice keeping track of how many redeemable tokens are in the tokenWhitelist uint private _redeemableCounter; /// @notice Address of the stablecoin. address private _stablecoin; /// @notice is registered ENS node identifying the oracle contract. bytes32 private _oracleNode; /// @notice Constructor initializes ENSResolvable, and Controllable. /// @param _ens_ is the ENS registry address. /// @param _oracleNode_ is the ENS node of the Oracle. /// @param _controllerNode_ is our Controllers node. /// @param _stablecoinAddress_ is the address of the stablecoint used by the wallet for the card load limit. constructor(address _ens_, bytes32 _oracleNode_, bytes32 _controllerNode_, address _stablecoinAddress_) ENSResolvable(_ens_) Controllable(_controllerNode_) public { _oracleNode = _oracleNode_; _stablecoin = _stablecoinAddress_; //a priori ERC20 whitelisted methods _methodIdWhitelist[_APPROVE] = true; _methodIdWhitelist[_BURN] = true; _methodIdWhitelist[_TRANSFER] = true; _methodIdWhitelist[_TRANSFER_FROM] = true; } modifier onlyAdminOrOracle() { address oracleAddress = _ensResolve(_oracleNode); require (_isAdmin(msg.sender) || msg.sender == oracleAddress, "either oracle or admin"); _; } /// @notice Add ERC20 tokens to the list of whitelisted tokens. /// @param _tokens ERC20 token contract addresses. /// @param _symbols ERC20 token names. /// @param _magnitude 10 to the power of number of decimal places used by each ERC20 token. /// @param _loadable is a bool that states whether or not a token is loadable to the TokenCard. /// @param _redeemable is a bool that states whether or not a token is redeemable in the TKN Holder Contract. /// @param _lastUpdate is a unit representing an ISO datetime e.g. 20180913153211. function addTokens(address[] calldata _tokens, bytes32[] calldata _symbols, uint[] calldata _magnitude, bool[] calldata _loadable, bool[] calldata _redeemable, uint _lastUpdate) external onlyAdmin { // Require that all parameters have the same length. require(_tokens.length == _symbols.length && _tokens.length == _magnitude.length && _tokens.length == _loadable.length && _tokens.length == _loadable.length, "parameter lengths do not match"); // Add each token to the list of supported tokens. for (uint i = 0; i < _tokens.length; i++) { // Require that the token isn't already available. require(!_tokenInfoMap[_tokens[i]].available, "token already available"); // Store the intermediate values. string memory symbol = _symbols[i].toSliceB32().toString(); // Add the token to the token list. _tokenInfoMap[_tokens[i]] = Token({ symbol : symbol, magnitude : _magnitude[i], rate : 0, available : true, loadable : _loadable[i], redeemable: _redeemable[i], lastUpdate : _lastUpdate }); // Add the token address to the address list. _tokenAddressArray.push(_tokens[i]); //if the token is redeemable increase the redeemableCounter if (_redeemable[i]){ _redeemableCounter = _redeemableCounter.add(1); } // Emit token addition event. emit AddedToken(msg.sender, _tokens[i], symbol, _magnitude[i], _loadable[i], _redeemable[i]); } } /// @notice Remove ERC20 tokens from the whitelist of tokens. /// @param _tokens ERC20 token contract addresses. function removeTokens(address[] calldata _tokens) external onlyAdmin { // Delete each token object from the list of supported tokens based on the addresses provided. for (uint i = 0; i < _tokens.length; i++) { // Store the token address. address token = _tokens[i]; //token must be available, reverts on duplicates as well require(_tokenInfoMap[token].available, "token is not available"); //if the token is redeemable decrease the redeemableCounter if (_tokenInfoMap[token].redeemable){ _redeemableCounter = _redeemableCounter.sub(1); } // Delete the token object. delete _tokenInfoMap[token]; // Remove the token address from the address list. for (uint j = 0; j < _tokenAddressArray.length.sub(1); j++) { if (_tokenAddressArray[j] == token) { _tokenAddressArray[j] = _tokenAddressArray[_tokenAddressArray.length.sub(1)]; break; } } _tokenAddressArray.length--; // Emit token removal event. emit RemovedToken(msg.sender, token); } } /// @notice based on the method it returns the recipient address and amount/value, ERC20 specific. /// @param _data is the transaction payload. function getERC20RecipientAndAmount(address _token, bytes calldata _data) external view returns (address, uint) { // Require that there exist enough bytes for encoding at least a method signature + data in the transaction payload: // 4 (signature) + 32(address or uint256) require(_data.length >= 4 + 32, "not enough method-encoding bytes"); // Get the method signature bytes4 signature = _data._bytesToBytes4(0); // Check if method Id is supported require(isERC20MethodSupported(_token, signature), "unsupported method"); // returns the recipient's address and amount is the value to be transferred if (signature == _BURN) { // 4 (signature) + 32(uint256) return (_token, _data._bytesToUint256(4)); } else if (signature == _TRANSFER_FROM) { // 4 (signature) + 32(address) + 32(address) + 32(uint256) require(_data.length >= 4 + 32 + 32 + 32, "not enough data for transferFrom"); return ( _data._bytesToAddress(4 + 32 + 12), _data._bytesToUint256(4 + 32 + 32)); } else { //transfer or approve // 4 (signature) + 32(address) + 32(uint) require(_data.length >= 4 + 32 + 32, "not enough data for transfer/appprove"); return (_data._bytesToAddress(4 + 12), _data._bytesToUint256(4 + 32)); } } /// @notice Toggles whether or not a token is loadable or not. function setTokenLoadable(address _token, bool _loadable) external onlyAdmin { // Require that the token exists. require(_tokenInfoMap[_token].available, "token is not available"); // this sets the loadable flag to the value passed in _tokenInfoMap[_token].loadable = _loadable; emit UpdatedTokenLoadable(msg.sender, _token, _loadable); } /// @notice Toggles whether or not a token is redeemable or not. function setTokenRedeemable(address _token, bool _redeemable) external onlyAdmin { // Require that the token exists. require(_tokenInfoMap[_token].available, "token is not available"); // this sets the redeemable flag to the value passed in _tokenInfoMap[_token].redeemable = _redeemable; emit UpdatedTokenRedeemable(msg.sender, _token, _redeemable); } /// @notice Update ERC20 token exchange rate. /// @param _token ERC20 token contract address. /// @param _rate ERC20 token exchange rate in wei. /// @param _updateDate date for the token updates. This will be compared to when oracle updates are received. function updateTokenRate(address _token, uint _rate, uint _updateDate) external onlyAdminOrOracle { // Require that the token exists. require(_tokenInfoMap[_token].available, "token is not available"); // Update the token's rate. _tokenInfoMap[_token].rate = _rate; // Update the token's last update timestamp. _tokenInfoMap[_token].lastUpdate = _updateDate; // Emit the rate update event. emit UpdatedTokenRate(msg.sender, _token, _rate); } //// @notice Withdraw tokens from the smart contract to the specified account. function claim(address payable _to, address _asset, uint _amount) external onlyAdmin { _safeTransfer(_to, _asset, _amount); emit Claimed(_to, _asset, _amount); } /// @notice This returns all of the fields for a given token. /// @param _a is the address of a given token. /// @return string of the token's symbol. /// @return uint of the token's magnitude. /// @return uint of the token's exchange rate to ETH. /// @return bool whether the token is available. /// @return bool whether the token is loadable to the TokenCard. /// @return bool whether the token is redeemable to the TKN Holder Contract. /// @return uint of the lastUpdated time of the token's exchange rate. function getTokenInfo(address _a) external view returns (string memory, uint256, uint256, bool, bool, bool, uint256) { Token storage tokenInfo = _tokenInfoMap[_a]; return (tokenInfo.symbol, tokenInfo.magnitude, tokenInfo.rate, tokenInfo.available, tokenInfo.loadable, tokenInfo.redeemable, tokenInfo.lastUpdate); } /// @notice This returns all of the fields for our StableCoin. /// @return string of the token's symbol. /// @return uint of the token's magnitude. /// @return uint of the token's exchange rate to ETH. /// @return bool whether the token is available. /// @return bool whether the token is loadable to the TokenCard. /// @return bool whether the token is redeemable to the TKN Holder Contract. /// @return uint of the lastUpdated time of the token's exchange rate. function getStablecoinInfo() external view returns (string memory, uint256, uint256, bool, bool, bool, uint256) { Token storage stablecoinInfo = _tokenInfoMap[_stablecoin]; return (stablecoinInfo.symbol, stablecoinInfo.magnitude, stablecoinInfo.rate, stablecoinInfo.available, stablecoinInfo.loadable, stablecoinInfo.redeemable, stablecoinInfo.lastUpdate); } /// @notice This returns an array of all whitelisted token addresses. /// @return address[] of whitelisted tokens. function tokenAddressArray() external view returns (address[] memory) { return _tokenAddressArray; } /// @notice This returns an array of all redeemable token addresses. /// @return address[] of redeemable tokens. function redeemableTokens() external view returns (address[] memory) { address[] memory redeemableAddresses = new address[](_redeemableCounter); uint redeemableIndex = 0; for (uint i = 0; i < _tokenAddressArray.length; i++) { address token = _tokenAddressArray[i]; if (_tokenInfoMap[token].redeemable){ redeemableAddresses[redeemableIndex] = token; redeemableIndex += 1; } } return redeemableAddresses; } /// @notice This returns true if a method Id is supported for the specific token. /// @return true if _methodId is supported in general or just for the specific token. function isERC20MethodSupported(address _token, bytes4 _methodId) public view returns (bool) { require(_tokenInfoMap[_token].available, "non-existing token"); return (_methodIdWhitelist[_methodId]); } /// @notice This returns true if the method is supported for all protected tokens. /// @return true if _methodId is in the method whitelist. function isERC20MethodWhitelisted(bytes4 _methodId) external view returns (bool) { return (_methodIdWhitelist[_methodId]); } /// @notice This returns the number of redeemable tokens. /// @return current # of redeemables. function redeemableCounter() external view returns (uint) { return _redeemableCounter; } /// @notice This returns the address of our stablecoin of choice. /// @return the address of the stablecoin contract. function stablecoin() external view returns (address) { return _stablecoin; } /// @notice this returns the node hash of our Oracle. /// @return the oracle node registered in ENS. function oracleNode() external view returns (bytes32) { return _oracleNode; } }
43,832
10
// mapping(uint256 => string) public poolNames;
string[] public poolNames; uint32 public poolCount; event SetPurpose(address sender, string purpose); event CreatePool(address sender, string name); string public purpose = "Yield farmers helping real farmers"; error EmptyPurposeError(uint code, string message);
string[] public poolNames; uint32 public poolCount; event SetPurpose(address sender, string purpose); event CreatePool(address sender, string name); string public purpose = "Yield farmers helping real farmers"; error EmptyPurposeError(uint code, string message);
29,070
138
// = keccak256("IncreaseAllowanceWithAuthorization(address owner,address spender,uint256 increment,uint256 validAfter,uint256 validBefore,bytes32 nonce)")
bytes32 public constant DECREASE_ALLOWANCE_WITH_AUTHORIZATION_TYPEHASH = 0xb70559e94cbda91958ebec07f9b65b3b490097c8d25c8dacd71105df1015b6d8;
bytes32 public constant DECREASE_ALLOWANCE_WITH_AUTHORIZATION_TYPEHASH = 0xb70559e94cbda91958ebec07f9b65b3b490097c8d25c8dacd71105df1015b6d8;
1,895
50
// Returns all rpc urls and their aliases as structs.
function rpcUrlStructs() external view returns (Rpc[] memory urls);
function rpcUrlStructs() external view returns (Rpc[] memory urls);
47,544
15
// Registration bol
controller.registerBOL(address(bol));
controller.registerBOL(address(bol));
26,136
23
// COMP token address
0xc00e94Cb662C3520282E6f5717214004A7f26888 );
0xc00e94Cb662C3520282E6f5717214004A7f26888 );
22,854
88
// Set the pair address.Don't allow changing whilst LP is staked (as this would prevent stakers getting their LP back) /
function setPairAddress(address pair) external owned { require(_totalLP == 0, "Cannot change pair whilst there is LP staked"); _pair = IERC20(pair); _pairInitialized = true; }
function setPairAddress(address pair) external owned { require(_totalLP == 0, "Cannot change pair whilst there is LP staked"); _pair = IERC20(pair); _pairInitialized = true; }
21,190
13
// Rock Paper Scissors Contract Constructor/Constructs the contract and initializes the queue./minBet the minimum bet required when making a move by calling `play`.
constructor(uint minBet) public
constructor(uint minBet) public
43,391
34
// Single liquidation function. Closes the vault if its ICR is lower than the minimum collateral ratio.
function liquidate(address _borrower) external override { _requireVaultIsActive(_borrower); address[] memory borrowers = new address[](1); borrowers[0] = _borrower; batchLiquidateVaults(borrowers); }
function liquidate(address _borrower) external override { _requireVaultIsActive(_borrower); address[] memory borrowers = new address[](1); borrowers[0] = _borrower; batchLiquidateVaults(borrowers); }
55,867
19
// Basic token Basic version of StandardToken, with no allowances. /
contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; /** * @dev total number of tokens in existence **/ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. **/ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. **/ function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } }
contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; /** * @dev total number of tokens in existence **/ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. **/ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. **/ function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } }
6,729
17
// /
uint256 treasuryShare; unchecked { treasuryShare = _amount * 2 / 3; }
uint256 treasuryShare; unchecked { treasuryShare = _amount * 2 / 3; }
22,303
58
// `allowed` tracks any extra transfer rights as in all ERC20 tokens
mapping(address => mapping(address => uint256)) internal allowed;
mapping(address => mapping(address => uint256)) internal allowed;
64,729
95
// Send ether amount to the fund collection wallet. override to create custom fund forwarding mechanisms
function forwardFunds(uint256 amount) internal;
function forwardFunds(uint256 amount) internal;
25,587
2
// Transfers punk to the smart contract owner /
function transfer(address punkContract, uint256 punkIndex) external returns (bool) { if (_owner != msg.sender) { return false; } // solhint-disable-next-line avoid-low-level-calls (bool result, ) = punkContract.call( abi.encodeWithSignature("transferPunk(address,uint256)", _owner, punkIndex) ); return result; }
function transfer(address punkContract, uint256 punkIndex) external returns (bool) { if (_owner != msg.sender) { return false; } // solhint-disable-next-line avoid-low-level-calls (bool result, ) = punkContract.call( abi.encodeWithSignature("transferPunk(address,uint256)", _owner, punkIndex) ); return result; }
27,024
20
// uint256 amountToken = calculatePoint(_mintAmount);
Auction memory currentAuction = auction; require(lock,"Wait for public sale"); require(block.timestamp >= currentAuction.firstStat, "Auction not started"); require(pointBalances[msg.sender] >= _mintAmountA + _mintAmountB + _mintAmountC, "Buy call option first"); uint256 amountETH = _mintAmountA * 3 * getAuctionPrice() + _mintAmountB * 2 * getAuctionPrice() + _mintAmountC * getAuctionPrice(); require( balanceOf(msg.sender) + _mintAmountA + _mintAmountB + _mintAmountC <= maxPerWallet, "exceed max wallet limit" ); require(msg.value == amountETH, "Must send the correct amount of ETH");
Auction memory currentAuction = auction; require(lock,"Wait for public sale"); require(block.timestamp >= currentAuction.firstStat, "Auction not started"); require(pointBalances[msg.sender] >= _mintAmountA + _mintAmountB + _mintAmountC, "Buy call option first"); uint256 amountETH = _mintAmountA * 3 * getAuctionPrice() + _mintAmountB * 2 * getAuctionPrice() + _mintAmountC * getAuctionPrice(); require( balanceOf(msg.sender) + _mintAmountA + _mintAmountB + _mintAmountC <= maxPerWallet, "exceed max wallet limit" ); require(msg.value == amountETH, "Must send the correct amount of ETH");
27,091
116
// returns the referee for a given address, if new, registers referee/referee the address of the referee for msg.sender/ return referee address from referral registry
function _getReferee(address referee) internal returns (address) { address sender = msg.sender; if (!referralRegistry.hasUserReferee(sender) && referee != address(0)) { referralRegistry.createReferralAnchor(sender, referee); } return referralRegistry.getUserReferee(sender); }
function _getReferee(address referee) internal returns (address) { address sender = msg.sender; if (!referralRegistry.hasUserReferee(sender) && referee != address(0)) { referralRegistry.createReferralAnchor(sender, referee); } return referralRegistry.getUserReferee(sender); }
77,731
45
// Transfer total allocated (minus previously claimed tokens)
newAmountClaimed = allocations[_recipient].totalAllocated;
newAmountClaimed = allocations[_recipient].totalAllocated;
54,450
123
// Exclusive upper limit on ECDSA signatures 'S' values. The valid range is given by fig (283) of the yellow paper.
uint256 private constant ECDSA_SIGNATURE_S_LIMIT = ECDSA_SIGNATURE_R_LIMIT / 2 + 1;
uint256 private constant ECDSA_SIGNATURE_S_LIMIT = ECDSA_SIGNATURE_R_LIMIT / 2 + 1;
23,820
10
// stop presale minting
bool public presaleActive = true;
bool public presaleActive = true;
4,931
488
// Terminate employee `_employeeId` on `@formatDate(_endDate)` _employeeId Employee's identifier _endDate Termination timestamp in seconds /
function terminateEmployee(uint256 _employeeId, uint64 _endDate) external authP(TERMINATE_EMPLOYEE_ROLE, arr(_employeeId, uint256(_endDate))) employeeActive(_employeeId)
function terminateEmployee(uint256 _employeeId, uint64 _endDate) external authP(TERMINATE_EMPLOYEE_ROLE, arr(_employeeId, uint256(_endDate))) employeeActive(_employeeId)
5,781
71
// ๆ“ไฝœๅญ˜่ฒจ-้€ฒ่ฒจ ๆญคๆ–นๆณ•ๅŸท่กŒ๏ผš - ็ด€้Œ„ๆ–ฐๅขž็š„็™ฝ้‡‘๏ผŒ็ด€้Œ„่ณ‡่จŠ๏ผš - index: ็™ฝ้‡‘็ทจ่™Ÿ - unit: ็™ฝ้‡‘ๅ–ฎไฝ - amount: ๆ•ธ้‡ - ipfs: ็™ฝ้‡‘่ญ‰ๆ˜ŽURL - ๅขžๅŠ ็™ฝ้‡‘็ธฝๅบซๅญ˜ๆ•ธ้‡๏ผŒ้‡็‚บamount Requires: - ๅŸท่กŒ่€…้ ˆ็‚บowner - ็™ฝ้‡‘็ทจ่™Ÿindexไธ่ƒฝ้‡่ค‡ - ๅ–ฎไฝ้ ˆ็ญ‰ๆ–ผ็›ฎๅ‰ๅˆ็ด„ๆ‰€่จญๅฎš็š„ๅ–ฎไฝ - ้‡amount้œ€ๅคงๆ–ผ0 Returns: - bool: ๅŸท่กŒๆˆๅŠŸๆ™‚๏ผŒๅ›žๅ‚ณtrue Events: - Stock: ๅŸท่กŒๆˆๅŠŸๆ™‚่งธ็™ผ /
function stock(string _index, string _unit, uint256 _amount, string _ipfs) onlyOwner returns (bool) { bytes32 _bindex = ConvertStringByte.stringToBytes32(_index); require(_amount > 0); require(_unit.toSlice().equals(unit.toSlice())); require(!(storehouse[_bindex].amount > 0)); Bullion bullion = storehouse[_bindex]; bullion.index = _index; bullion.unit = _unit; bullion.amount = _amount; bullion.ipfs = _ipfs; // ๅŠ ๅ…ฅๅ€‰ๅ„ฒ็›ฎ้Œ„ storehouseIndex.push(_bindex); // ๅŠ ๅ…ฅๅ€‰ๅ„ฒ storehouse[_bindex] = bullion; // ๅขžๅŠ ็ธฝๅบซๅญ˜ total = total.add(_amount); Stock(bullion.index, bullion.unit, bullion.amount, bullion.ipfs, total); return true; }
function stock(string _index, string _unit, uint256 _amount, string _ipfs) onlyOwner returns (bool) { bytes32 _bindex = ConvertStringByte.stringToBytes32(_index); require(_amount > 0); require(_unit.toSlice().equals(unit.toSlice())); require(!(storehouse[_bindex].amount > 0)); Bullion bullion = storehouse[_bindex]; bullion.index = _index; bullion.unit = _unit; bullion.amount = _amount; bullion.ipfs = _ipfs; // ๅŠ ๅ…ฅๅ€‰ๅ„ฒ็›ฎ้Œ„ storehouseIndex.push(_bindex); // ๅŠ ๅ…ฅๅ€‰ๅ„ฒ storehouse[_bindex] = bullion; // ๅขžๅŠ ็ธฝๅบซๅญ˜ total = total.add(_amount); Stock(bullion.index, bullion.unit, bullion.amount, bullion.ipfs, total); return true; }
38,563
90
// Get ICoFiXRouter implementation contract address for CoFiX/ return ICoFiXRouter implementation contract address for CoFiX
function getCoFiXRouterAddress() external view returns (address);
function getCoFiXRouterAddress() external view returns (address);
27,601
273
// get the rate between the reserves upon adding liquidity and now
Fraction memory addSpotRate = Fraction({ n: packedRates.addSpotRateN, d: packedRates.addSpotRateD });
Fraction memory addSpotRate = Fraction({ n: packedRates.addSpotRateN, d: packedRates.addSpotRateD });
2,705
206
// There has to be at least one Safe owner.
require(_threshold >= 1, "GS202");
require(_threshold >= 1, "GS202");
26,734
111
// BLACKHAT PROTECTION
bool public _hasLiqBeenAdded = false; mapping (address => bool) private _liquidityHolders; mapping (address => bool) private _isSniper; uint256 private _liqAddBlock; uint256 private snipeBlockAmt; uint256 public snipersCaught; event SniperCaught(address sniperAddress);
bool public _hasLiqBeenAdded = false; mapping (address => bool) private _liquidityHolders; mapping (address => bool) private _isSniper; uint256 private _liqAddBlock; uint256 private snipeBlockAmt; uint256 public snipersCaught; event SniperCaught(address sniperAddress);
15,998
3
// user functions //Send an ERC20 token/ access control: only owner/ state machine:/ - can be called multiple times/ - only online/ state scope: none/ token transfer: transfer tokens from self to recipient/token address The token to send/to address The recipient to send to/value uint256 Amount of tokens to send
function sendERC20( address token, address to, uint256 value
function sendERC20( address token, address to, uint256 value
10,741
183
// Get tokens to mint 100000x
uint256 tokens100000xPerMinuteRate = eras[eraIndex].tokens100000xPerMinuteRate; uint256 tokens100000x = minutesSinceLastMint.mul(tokens100000xPerMinuteRate);
uint256 tokens100000xPerMinuteRate = eras[eraIndex].tokens100000xPerMinuteRate; uint256 tokens100000x = minutesSinceLastMint.mul(tokens100000xPerMinuteRate);
16,597
1
// Number of ExpansionPunks reserved for promotion & giveaways
uint8 public totalReserved = 11;
uint8 public totalReserved = 11;
42,895
5
// every time a trader's position value is checked, the base token list of this trader will be traversed;/thus, this list should be kept as short as possible/trader The address of the trader/baseToken The address of the trader's base token
function registerBaseToken(address trader, address baseToken) external;
function registerBaseToken(address trader, address baseToken) external;
33,480
36
// TO DO ไฝฟ็”จไบ‚ๆ•ธไพ†็”ข็”ŸDNA, ๆ˜Ÿ็ดš, ๅ‹•็‰ฉ็จฎ้กž
dna = random(); uint ram = uint(random()) % 100;
dna = random(); uint ram = uint(random()) % 100;
16,890
215
// start next round
rID_++; _rID++; round_[_rID].strt = now; round_[_rID].end = now.add(rndInit_).add(rndGap_); round_[_rID].pot = _res; return(_eventData_);
rID_++; _rID++; round_[_rID].strt = now; round_[_rID].end = now.add(rndInit_).add(rndGap_); round_[_rID].pot = _res; return(_eventData_);
3,535
3
// State variable storing the number of times fallback function was called.
uint fallbackCounter = 0;
uint fallbackCounter = 0;
30,362
59
// if (myBet.resolved) {continue;}myBet.resolved = true;
bool result = targets[myBet.target]; uint256 potentialWinningAmount = myBet.potentialWinningAmount; if (result) { lockUserBalance_0Hao( myBet.roomId, myBet.bettor ); userBalances[myBet.roomId][ myBet.bettor ] += potentialWinningAmount;
bool result = targets[myBet.target]; uint256 potentialWinningAmount = myBet.potentialWinningAmount; if (result) { lockUserBalance_0Hao( myBet.roomId, myBet.bettor ); userBalances[myBet.roomId][ myBet.bettor ] += potentialWinningAmount;
2,276
60
// beneficiary of tokens after they are released
address public beneficiary;
address public beneficiary;
8,382
29
// mapping that contains all the farming contract linked to this extension
address internal _farmingContract;
address internal _farmingContract;
30,982
54
// return The total number of fragments. /
function totalSupply() public view returns (uint256) { return info.totalSupply; }
function totalSupply() public view returns (uint256) { return info.totalSupply; }
10,465
29
// return enabledlockingNFTs state, access: ANY/ if true user can't unlock NFT and vice versa
function enabledlockingNFTs() external view returns (bool);
function enabledlockingNFTs() external view returns (bool);
59,751
13
// Deal action to start a new game with proxy mode, submit by croupier bot.gambler gambler's address.commit generated by keccak of 2 256-bit reveals, used to unique identify a deck. gambler get commit but don't know the deck, dealer can't change the deck because of keccak is one-way irreversible.amount 128-bit number of bet amount.cutCard cut card position, gambler set it after receive the commit, so this process can guarantee fairness.v r s v, r,s are components of ECDSA signature. Ensure the deck is signed by the gambler himself. /
function deal(address gambler, uint256 commit, uint128 amount, uint8 cutCard, uint8 v, bytes32 r, bytes32 s) public onlyCroupier
function deal(address gambler, uint256 commit, uint128 amount, uint8 cutCard, uint8 v, bytes32 r, bytes32 s) public onlyCroupier
49,383
1
// Returns true if `gauge` was created by this factory. /
function isGaugeFromFactory(address gauge) external view returns (bool);
function isGaugeFromFactory(address gauge) external view returns (bool);
22,811
64
// withdraw NAC and ETH for non top investor execute by investor
function withdrawNonTop(uint _roundIndex) public
function withdrawNonTop(uint _roundIndex) public
43,701
9
// Enter markets
address[] memory cTokens = new address[](1); cTokens[0] = fuse_pools_array[i]; IComptroller(_initial_unitrollers[i]).enterMarkets(cTokens);
address[] memory cTokens = new address[](1); cTokens[0] = fuse_pools_array[i]; IComptroller(_initial_unitrollers[i]).enterMarkets(cTokens);
56,797
4
// total supply(modified for etherscan display)
function totalSupply() constant returns (uint256) { return activeSupply(); }
function totalSupply() constant returns (uint256) { return activeSupply(); }
45,029
35
// get nft details
NftDetails[] memory nftDetails; (nftDetails) = abi.decode( data, (NftDetails[]) );
NftDetails[] memory nftDetails; (nftDetails) = abi.decode( data, (NftDetails[]) );
25,954
1
// Fiat currencies follow https:en.wikipedia.org/wiki/ISO_4217
address public constant USD = address(840); address public constant GBP = address(826); address public constant EUR = address(978);
address public constant USD = address(840); address public constant GBP = address(826); address public constant EUR = address(978);
34,204
221
// calculate time based on number of keys bought
uint256 _newTime; if (_now > round_[_rID].end && round_[_rID].plyr == 0) _newTime = (((_keys) / (1000000000000000000)).mul(rndInc_)).add(_now); else _newTime = (((_keys) / (1000000000000000000)).mul(rndInc_)).add(round_[_rID].end);
uint256 _newTime; if (_now > round_[_rID].end && round_[_rID].plyr == 0) _newTime = (((_keys) / (1000000000000000000)).mul(rndInc_)).add(_now); else _newTime = (((_keys) / (1000000000000000000)).mul(rndInc_)).add(round_[_rID].end);
3,540
5
// Miningamount Number of handling chargesblockNum Offer block numbertarget Transfer targettoken Token address return Ore yield/
function mining(uint256 amount, uint256 blockNum, address target, address token) public returns(uint256) { require(address(msg.sender) == offerFactoryAddress); uint256 miningAmount = amount.mul(blockMining[blockNum]).div(blockEth[blockNum][token].mul(blockTokenNum[blockNum])); uint256 realAmount = miningSave.turnOut(miningAmount, target); emit miningLog(blockNum, token,blockEth[blockNum][token],amount,blockTokenNum[blockNum]); return realAmount; }
function mining(uint256 amount, uint256 blockNum, address target, address token) public returns(uint256) { require(address(msg.sender) == offerFactoryAddress); uint256 miningAmount = amount.mul(blockMining[blockNum]).div(blockEth[blockNum][token].mul(blockTokenNum[blockNum])); uint256 realAmount = miningSave.turnOut(miningAmount, target); emit miningLog(blockNum, token,blockEth[blockNum][token],amount,blockTokenNum[blockNum]); return realAmount; }
4,949
118
// Fund the farm, increase the end block
function fund(uint256 _amount) public { require(block.number < endBlock, "fund: too late, the farm is closed"); erc20.safeTransferFrom(address(msg.sender), address(this), _amount); endBlock += _amount.div(rewardPerBlock); }
function fund(uint256 _amount) public { require(block.number < endBlock, "fund: too late, the farm is closed"); erc20.safeTransferFrom(address(msg.sender), address(this), _amount); endBlock += _amount.div(rewardPerBlock); }
12,164
133
// setRenewable - sets if a product is renewable_productId - the product id_newRenewable - the new renewable setting/
function setRenewable(uint256 _productId, bool _newRenewable) external onlyCLevel
function setRenewable(uint256 _productId, bool _newRenewable) external onlyCLevel
42,771
285
// (uint8 TradeActionType, uint8 MarketIndex, uint88 assetCashAmount, uint32 minImpliedRate, uint32 maxImpliedRate, uint88 unused)
AddLiquidity,
AddLiquidity,
5,919