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
106
// Ensures that collateralAssetAvailable does not go below zero
int256 collateralUnderlyingAvailable = c.factors.collateralCashGroup.assetRate.convertToUnderlying(c.factors.collateralAssetAvailable); if (fCashRiskAdjustedUnderlyingPV > collateralUnderlyingAvailable) {
int256 collateralUnderlyingAvailable = c.factors.collateralCashGroup.assetRate.convertToUnderlying(c.factors.collateralAssetAvailable); if (fCashRiskAdjustedUnderlyingPV > collateralUnderlyingAvailable) {
70,261
199
// uint256 public RESERVED_NFT = 6000;
uint256 public NFT_PRICE = 0.18 ether; uint256 public NFT_PRICE_PRESALE = 0.09 ether; uint256 public MAX_NFT_WALLET_PRESALE = 3; uint256 public MAX_NFT_WALLET = 10; bool public saleIsActive = false; uint256 public publicSaleStartTimestamp;
uint256 public NFT_PRICE = 0.18 ether; uint256 public NFT_PRICE_PRESALE = 0.09 ether; uint256 public MAX_NFT_WALLET_PRESALE = 3; uint256 public MAX_NFT_WALLET = 10; bool public saleIsActive = false; uint256 public publicSaleStartTimestamp;
58,612
220
// It allows owner to set the fee address_feeAddress : fee address /
function setFeeAddress(address _feeAddress)
function setFeeAddress(address _feeAddress)
19,616
44
// if no affiliate code was given or player tried to use their own, lolz
if (_affCode == address(0) || _affCode == msg.sender) {
if (_affCode == address(0) || _affCode == msg.sender) {
31,607
124
// Allow staking at any time without earning undue rewards The following is guaranteed if the next `if` is true: lastUpdateTime == previous _periodEndTime || lastUpdateTime == 0
if (_periodStartTime > lastUpdateTime) {
if (_periodStartTime > lastUpdateTime) {
25,306
59
// the UNIX timestamp start date of the crowdsale
uint public startsAt;
uint public startsAt;
69,231
24
// ------------------------------------------------------------------------ Don't accept ETH ------------------------------------------------------------------------
// function () external payable { // revert(); // }
// function () external payable { // revert(); // }
21,444
17
// , PermissionsEnumerable
contract MySignatureDrop2 is ERC721Drop { /// Add by Joe~ //bytes32 private coverRole; string private _coverUri; // bytes32 public constant COVER_ROLE = keccak256("COVER_ROLE"); bool private isCover = true; constructor( string memory _name, string memory _symbol, address _royaltyRecipient, uint128 _royaltyBps, address _primarySaleRecipient ) ERC721Drop( _name, _symbol, _royaltyRecipient, _royaltyBps, _primarySaleRecipient ) { //add by Joe~ //bytes32 _transferRole = keccak256("TRANSFER_ROLE"); //bytes32 _minterRole = keccak256("MINTER_ROLE"); //address defaultAdmin = msg.sender; //_setupOwner(defaultAdmin); //_setupRole(DEFAULT_ADMIN_ROLE, defaultAdmin); //_setupRole(_minterRole, defaultAdmin); //_setupRole(_transferRole, defaultAdmin); //_setupRole(_transferRole, address(0)); //_setupRole(COVER_ROLE, defaultAdmin); // coverRole = COVER_ROLE; _coverUri = "ipfs://QmVAKcAmjeUWW3GpCmrRNm6Qzpk1FWJ4BT5yEvUNySdeuj/5"; } /// tweek by Joe~ function tokenURI(uint256 _tokenId) public view override returns (string memory) { //add by Joe~ if (isCover) { return _coverUri; } return super.tokenURI(_tokenId); } //add by joe~ function getCoverUri() public view returns (string memory) { return _coverUri; } //add by joe~ event CoverEvent(string message); //add by joe~ function setCoverUri( string calldata newUri //onlyRole(COVER_ROLE) ) public { if (bytes(newUri).length == 0) { emit CoverEvent("set empty cover uri. skip it"); } _coverUri = newUri; emit CoverEvent(string(abi.encodePacked("change to ", newUri))); } //add by joe~ function switchCover() public //onlyRole(COVER_ROLE) { isCover = !isCover; emit CoverEvent(isCover ? "cover" : "reveal"); } }
contract MySignatureDrop2 is ERC721Drop { /// Add by Joe~ //bytes32 private coverRole; string private _coverUri; // bytes32 public constant COVER_ROLE = keccak256("COVER_ROLE"); bool private isCover = true; constructor( string memory _name, string memory _symbol, address _royaltyRecipient, uint128 _royaltyBps, address _primarySaleRecipient ) ERC721Drop( _name, _symbol, _royaltyRecipient, _royaltyBps, _primarySaleRecipient ) { //add by Joe~ //bytes32 _transferRole = keccak256("TRANSFER_ROLE"); //bytes32 _minterRole = keccak256("MINTER_ROLE"); //address defaultAdmin = msg.sender; //_setupOwner(defaultAdmin); //_setupRole(DEFAULT_ADMIN_ROLE, defaultAdmin); //_setupRole(_minterRole, defaultAdmin); //_setupRole(_transferRole, defaultAdmin); //_setupRole(_transferRole, address(0)); //_setupRole(COVER_ROLE, defaultAdmin); // coverRole = COVER_ROLE; _coverUri = "ipfs://QmVAKcAmjeUWW3GpCmrRNm6Qzpk1FWJ4BT5yEvUNySdeuj/5"; } /// tweek by Joe~ function tokenURI(uint256 _tokenId) public view override returns (string memory) { //add by Joe~ if (isCover) { return _coverUri; } return super.tokenURI(_tokenId); } //add by joe~ function getCoverUri() public view returns (string memory) { return _coverUri; } //add by joe~ event CoverEvent(string message); //add by joe~ function setCoverUri( string calldata newUri //onlyRole(COVER_ROLE) ) public { if (bytes(newUri).length == 0) { emit CoverEvent("set empty cover uri. skip it"); } _coverUri = newUri; emit CoverEvent(string(abi.encodePacked("change to ", newUri))); } //add by joe~ function switchCover() public //onlyRole(COVER_ROLE) { isCover = !isCover; emit CoverEvent(isCover ? "cover" : "reveal"); } }
17,125
14
// Getter to access paused /
function paused() external view override returns (bool) { return _paused; }
function paused() external view override returns (bool) { return _paused; }
22,995
54
// We implicitly trust the ERC20 controller. Send it the ETH we got from the sell.
Address.sendValue(payable(_controller), amt);
Address.sendValue(payable(_controller), amt);
12,907
40
// whitelist proposal
if (proposal.flags[4] == 1) { require(!tokenWhitelist[address(proposal.tributeToken)], "whitelisted"); require(!proposedToWhitelist[address(proposal.tributeToken)], "whitelist proposed"); require(approvedTokens.length < MAX_TOKEN_WHITELIST_COUNT, "whitelist maxed"); proposedToWhitelist[address(proposal.tributeToken)] = true;
if (proposal.flags[4] == 1) { require(!tokenWhitelist[address(proposal.tributeToken)], "whitelisted"); require(!proposedToWhitelist[address(proposal.tributeToken)], "whitelist proposed"); require(approvedTokens.length < MAX_TOKEN_WHITELIST_COUNT, "whitelist maxed"); proposedToWhitelist[address(proposal.tributeToken)] = true;
18,101
37
// Team tokens (10M) locked till Jan 01, 2022 and will be relesed each 3 months by 25% 1640995200= January 1, 2022 12:00:00 AM GMT team tokens: 10,000,000 Token
uint8 teamLockPool = _addVestingPool("Team Lock" , 1640995200, 4, 90 days); _addBeneficiary(teamLockPool, 0x4608f8245258e93aF27A15f9fBA17515149f4435,4000000); // 4,000,000 Tokens _addBeneficiary(teamLockPool, 0x5a4D85F03d9C45907617bABcDc7f4C5599c4cE19,2000000); // 2,000,000 Tokens _addBeneficiary(teamLockPool, 0x28eFeB6bf726bc9b1b2b989Cada5D9C95CfBb38C,1333334); // 1,333,334 Tokens _addBeneficiary(teamLockPool, 0x971945b040B126dCe5aD2982FBD2a72d4Ba3966c,1333333); // 1,333,333 Tokens _addBeneficiary(teamLockPool, 0xd558D2A872185C64DE4BF2a63Ad0Bc307f861997,1333333); // 1,333,333 Tokens
uint8 teamLockPool = _addVestingPool("Team Lock" , 1640995200, 4, 90 days); _addBeneficiary(teamLockPool, 0x4608f8245258e93aF27A15f9fBA17515149f4435,4000000); // 4,000,000 Tokens _addBeneficiary(teamLockPool, 0x5a4D85F03d9C45907617bABcDc7f4C5599c4cE19,2000000); // 2,000,000 Tokens _addBeneficiary(teamLockPool, 0x28eFeB6bf726bc9b1b2b989Cada5D9C95CfBb38C,1333334); // 1,333,334 Tokens _addBeneficiary(teamLockPool, 0x971945b040B126dCe5aD2982FBD2a72d4Ba3966c,1333333); // 1,333,333 Tokens _addBeneficiary(teamLockPool, 0xd558D2A872185C64DE4BF2a63Ad0Bc307f861997,1333333); // 1,333,333 Tokens
14,818
9
// burn a token. Can only be called by token owner or approved address.On burn, calls back to the registered extension's onBurn method /
function burn(uint256 tokenId) external;
function burn(uint256 tokenId) external;
7,638
31
// retrieve the size of the code on target address, this needs assembly
length := extcodesize(_addr)
length := extcodesize(_addr)
10,947
77
// Prevent sells
require(recipient != pair);
require(recipient != pair);
12,544
275
// If we do not have enough collateral, try to get some via COMP This scenario is rare and will happen during last withdraw
if (_amount > cToken.balanceOfUnderlying(address(this))) {
if (_amount > cToken.balanceOfUnderlying(address(this))) {
66,389
126
// check if user gradual has any non-matured tranches_userGradual user gradual structreturn hasTranches true if user has non-matured tranches /
function _hasTranches(UserGradual memory _userGradual) private pure returns (bool hasTranches) { if (_userGradual.oldestTranchePosition.arrayIndex > 0) { hasTranches = true; } }
function _hasTranches(UserGradual memory _userGradual) private pure returns (bool hasTranches) { if (_userGradual.oldestTranchePosition.arrayIndex > 0) { hasTranches = true; } }
39,888
1
// Emitted after the cooldownTime has been updated. rateFeedID The rateFeedID targeted. newCooldownTime The new cooldownTime of the breaker. /
event RateFeedCooldownTimeUpdated(address rateFeedID, uint256 newCooldownTime);
event RateFeedCooldownTimeUpdated(address rateFeedID, uint256 newCooldownTime);
22,666
29
// Moves tokens `amount` from `sender` to `recipient`. This is internal function is equivalent to `transfer`, and can be used toe.g. implement automatic token fees, slashing mechanisms, etc. Emits a `Transfer` event. Requirements: - `sender` cannot be the zero address.- `recipient` cannot be the zero address.- `sender` must have a balance of at least `amount`. /
function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); }
function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); }
802
189
// stake CUDO in a specific reward programme that dictates a minimum lockup period
function stake(uint256 _programmeId, address _from, uint256 _amount) external nonReentrant paused notZero(_amount) unkSP { RewardProgramme storage rewardProgramme = rewardProgrammes[_programmeId]; UserInfo storage user = userInfo[_programmeId][_msgSender()]; user.amount = user.amount.add(_amount); rewardProgramme.totalStaked = rewardProgramme.totalStaked.add(_amount); totalCudosStaked = totalCudosStaked.add(_amount); // weigted sum gets updated when new tokens are staked weightedTotalCudosStaked = weightedTotalCudosStaked.add(_amount.mul(rewardProgramme.allocPoint)); user.rewardDebt = user.amount.mul(rewardProgramme.accTokensPerShare).div(1e18); token.safeTransferFrom(address(_from), address(rewardsGuildBank), _amount); emit Deposit(_from, _programmeId, _amount); }
function stake(uint256 _programmeId, address _from, uint256 _amount) external nonReentrant paused notZero(_amount) unkSP { RewardProgramme storage rewardProgramme = rewardProgrammes[_programmeId]; UserInfo storage user = userInfo[_programmeId][_msgSender()]; user.amount = user.amount.add(_amount); rewardProgramme.totalStaked = rewardProgramme.totalStaked.add(_amount); totalCudosStaked = totalCudosStaked.add(_amount); // weigted sum gets updated when new tokens are staked weightedTotalCudosStaked = weightedTotalCudosStaked.add(_amount.mul(rewardProgramme.allocPoint)); user.rewardDebt = user.amount.mul(rewardProgramme.accTokensPerShare).div(1e18); token.safeTransferFrom(address(_from), address(rewardsGuildBank), _amount); emit Deposit(_from, _programmeId, _amount); }
46,556
12
// disregard overflows on block.timestamp, see MAX_TIMESTAMP
return dayBase(uint128(block.timestamp));
return dayBase(uint128(block.timestamp));
6,674
180
// Set Public Sale Cost
function setCost(uint256 _newCost) public onlyOwner() { publicCost = _newCost; }
function setCost(uint256 _newCost) public onlyOwner() { publicCost = _newCost; }
76,298
10
// A mapping from CardIDs to the price of the token.
mapping (uint256 => uint256) private cardIndexToPrice;
mapping (uint256 => uint256) private cardIndexToPrice;
886
13
// burn batch function
function burnBatch( address from, uint256[] memory tokenIds, uint256[] memory amounts
function burnBatch( address from, uint256[] memory tokenIds, uint256[] memory amounts
5,336
280
// Calculates final amountOut, and the fee and final amount in
(uint exitFee, uint amountOut) = SmartPoolManager.exitswapPoolAmountIn( IConfigurableRightsPool(address(this)), bPool, tokenOut, poolAmountIn, minAmountOut ); tokenAmountOut = amountOut;
(uint exitFee, uint amountOut) = SmartPoolManager.exitswapPoolAmountIn( IConfigurableRightsPool(address(this)), bPool, tokenOut, poolAmountIn, minAmountOut ); tokenAmountOut = amountOut;
11,696
35
// or the governance wants this to happen
|| msg.sender == governance(), "Buffer exists and the caller is not governance" );
|| msg.sender == governance(), "Buffer exists and the caller is not governance" );
27,995
2
// SPDX-License-Identifier: MIT a library for performing overflow-safe math, updated with awesomeness from of DappHub (https:github.com/dapphub/ds-math)
library BoringMath { function add(uint256 a, uint256 b) internal pure returns (uint256 c) {require((c = a + b) >= b, "BoringMath: Add Overflow");} function sub(uint256 a, uint256 b) internal pure returns (uint256 c) {require((c = a - b) <= a, "BoringMath: Underflow");} function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {require(b == 0 || (c = a * b)/b == a, "BoringMath: Mul Overflow");} function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "BoringMath: Division by zero"); return a / b; } function to128(uint256 a) internal pure returns (uint128 c) { require(a <= uint128(-1), "BoringMath: uint128 Overflow"); c = uint128(a); } }
library BoringMath { function add(uint256 a, uint256 b) internal pure returns (uint256 c) {require((c = a + b) >= b, "BoringMath: Add Overflow");} function sub(uint256 a, uint256 b) internal pure returns (uint256 c) {require((c = a - b) <= a, "BoringMath: Underflow");} function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {require(b == 0 || (c = a * b)/b == a, "BoringMath: Mul Overflow");} function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "BoringMath: Division by zero"); return a / b; } function to128(uint256 a) internal pure returns (uint128 c) { require(a <= uint128(-1), "BoringMath: uint128 Overflow"); c = uint128(a); } }
32,805
6
// REGULAR PRESALE MINTING 0.015 ETHER
uint256 supply = totalSupply(); require( supply + 1 <= 6666 - _reserved, "Exceeds maximum supply" ); require(isPreListed(msg.sender), "user is not eligible for presale"); require( msg.value >= presaleprice * 1, "Ether sent is not correct" ); _safeMint( msg.sender, supply + 1); for (uint i = 0; i < presaleAddresses.length; i++) { if (presaleAddresses[i] == msg.sender) { delete presaleAddresses[i]; break;
uint256 supply = totalSupply(); require( supply + 1 <= 6666 - _reserved, "Exceeds maximum supply" ); require(isPreListed(msg.sender), "user is not eligible for presale"); require( msg.value >= presaleprice * 1, "Ether sent is not correct" ); _safeMint( msg.sender, supply + 1); for (uint i = 0; i < presaleAddresses.length; i++) { if (presaleAddresses[i] == msg.sender) { delete presaleAddresses[i]; break;
23,639
3
// Loads a storage slot from an address (who, slot)
function load(address,bytes32) external returns (bytes32);
function load(address,bytes32) external returns (bytes32);
28,087
1
// Try to reenter `batchExecuteMetaTransactions()`
IMetaTransactionsFeature.MetaTransactionData[] memory mtxs = new IMetaTransactionsFeature.MetaTransactionData[](1); LibSignature.Signature[] memory signatures = new LibSignature.Signature[](1); mtxs[0] = IMetaTransactionsFeature.MetaTransactionData({ signer: address(0), sender: address(0), minGasPrice: 0, maxGasPrice: 0, expirationTimeSeconds: 0, salt: 0,
IMetaTransactionsFeature.MetaTransactionData[] memory mtxs = new IMetaTransactionsFeature.MetaTransactionData[](1); LibSignature.Signature[] memory signatures = new LibSignature.Signature[](1); mtxs[0] = IMetaTransactionsFeature.MetaTransactionData({ signer: address(0), sender: address(0), minGasPrice: 0, maxGasPrice: 0, expirationTimeSeconds: 0, salt: 0,
8,893
4
// TODO: check addresses equals to tokens
require(msg.sender == resolver, "Market: FORBIDDEN"); require(_outcome.length == tokens.length, "Market: MISSING_OUTCOMES"); require(block.timestamp >= timestamp, "Market: TOO_EARLY"); uint256 totalIncome = 0; for (uint256 i = 0; i < _outcome.length; i++) { require(_outcome[i].result >= 0 && _outcome[i].result <= 100, "Market: WRONG_RESULT"); outcome[_outcome[i].token] = _outcome[i].result; totalIncome += _outcome[i].result; }
require(msg.sender == resolver, "Market: FORBIDDEN"); require(_outcome.length == tokens.length, "Market: MISSING_OUTCOMES"); require(block.timestamp >= timestamp, "Market: TOO_EARLY"); uint256 totalIncome = 0; for (uint256 i = 0; i < _outcome.length; i++) { require(_outcome[i].result >= 0 && _outcome[i].result <= 100, "Market: WRONG_RESULT"); outcome[_outcome[i].token] = _outcome[i].result; totalIncome += _outcome[i].result; }
20,323
103
// import {DripsReceiver, SplitsReceiver} from "./Structs.sol"; //On every timestamp `T`, which is a multiple of `cycleSecs`, the receivers/ gain access to drips collected during `T - cycleSecs` to `T - 1`.
uint64 public immutable cycleSecs;
uint64 public immutable cycleSecs;
24,833
10
// query if the _libraryAddress is valid for receiving msgs._userApplication - the user app address on this EVM chain
function getReceiveLibraryAddress( address _userApplication ) external view returns (address);
function getReceiveLibraryAddress( address _userApplication ) external view returns (address);
8,722
79
// NFT上のマーケットへの出品
struct Markets { // 登録時のNFT売手 address seller; // 価格 uint128 marketsPrice; }
struct Markets { // 登録時のNFT売手 address seller; // 価格 uint128 marketsPrice; }
31,576
152
// Remember that the `_staker` staked into `_poolStakingAddress`
address[] storage stakerPools = _stakerPools[_staker]; uint256 index = _stakerPoolsIndexes[_staker][_poolStakingAddress]; if (index >= stakerPools.length || stakerPools[index] != _poolStakingAddress) { _stakerPoolsIndexes[_staker][_poolStakingAddress] = stakerPools.length; stakerPools.push(_poolStakingAddress); }
address[] storage stakerPools = _stakerPools[_staker]; uint256 index = _stakerPoolsIndexes[_staker][_poolStakingAddress]; if (index >= stakerPools.length || stakerPools[index] != _poolStakingAddress) { _stakerPoolsIndexes[_staker][_poolStakingAddress] = stakerPools.length; stakerPools.push(_poolStakingAddress); }
6,820
77
// Erase the resolver and owner records
ens.setResolver(node, address(0x0)); ens.setOwner(node, address(0x0));
ens.setResolver(node, address(0x0)); ens.setOwner(node, address(0x0));
39,074
5
// This functions show your current balance in your address
function getFunds () isClient constant returns (uint){ return this.balance; }
function getFunds () isClient constant returns (uint){ return this.balance; }
41,852
230
// res += val(coefficients[56] + coefficients[57]adjustments[7]).
res := addmod(res, mulmod(val, add(/*coefficients[56]*/ mload(0xb40), mulmod(/*coefficients[57]*/ mload(0xb60),
res := addmod(res, mulmod(val, add(/*coefficients[56]*/ mload(0xb40), mulmod(/*coefficients[57]*/ mload(0xb60),
20,734
18
// Warning: you should absolutely sure you want to give up authority!!!
function disableOwnership() public onlyOwner { owner = address(0); emit OwnerUpdate(msg.sender, owner); }
function disableOwnership() public onlyOwner { owner = address(0); emit OwnerUpdate(msg.sender, owner); }
24,010
36
// Initializes the Contract Dependencies as well as the Holiday Mapping for OwnTheDay.io /
function initialize(address _dateTimeAddress, address _tokenAddress, address _otdAddress) public onlyOwner { DateTimeLib_ = DateTime(_dateTimeAddress); CryptoTorchToken_ = CryptoTorchToken(_tokenAddress); OwnTheDayContract_ = OwnTheDayContract(_otdAddress); holidayMap_[0] = "10000110000001100000000000000101100000000011101000000000000011000000000000001001000010000101100010100110000100001000110000"; holidayMap_[1] = "10111000100101000111000000100100000100010001001000100000000010010000000001000000110000000000000100000000010001100001100000"; holidayMap_[2] = "01000000000100000101011000000110000001100000000100000000000011100001000100000000101000000000100000000000000000010011000001"; }
function initialize(address _dateTimeAddress, address _tokenAddress, address _otdAddress) public onlyOwner { DateTimeLib_ = DateTime(_dateTimeAddress); CryptoTorchToken_ = CryptoTorchToken(_tokenAddress); OwnTheDayContract_ = OwnTheDayContract(_otdAddress); holidayMap_[0] = "10000110000001100000000000000101100000000011101000000000000011000000000000001001000010000101100010100110000100001000110000"; holidayMap_[1] = "10111000100101000111000000100100000100010001001000100000000010010000000001000000110000000000000100000000010001100001100000"; holidayMap_[2] = "01000000000100000101011000000110000001100000000100000000000011100001000100000000101000000000100000000000000000010011000001"; }
64,465
39
// The current price for a single indivisible part of a token. If a buyin happens now, this is/ the highest price per indivisible token part that the buyer will pay. This doesn't/ include the discount which may be available.
function currentPrice() public constant when_active returns (uint weiPerIndivisibleTokenPart) { return (USDWEI * 40000000 / (now - beginTime + 5760) - USDWEI * 5) / DIVISOR; }
function currentPrice() public constant when_active returns (uint weiPerIndivisibleTokenPart) { return (USDWEI * 40000000 / (now - beginTime + 5760) - USDWEI * 5) / DIVISOR; }
7,817
6
// If the last available tokenID is still unused...
if (tokenMatrix[maxIndex - 1] == 0) {
if (tokenMatrix[maxIndex - 1] == 0) {
7,458
141
// Read cToken balance
(oErr, supplyBalance, , exchangeRateMantissa) = cToken.getAccountSnapshot(account); if (oErr != 0) { return (Error.SNAPSHOT_ERROR, 0, 0); }
(oErr, supplyBalance, , exchangeRateMantissa) = cToken.getAccountSnapshot(account); if (oErr != 0) { return (Error.SNAPSHOT_ERROR, 0, 0); }
38,204
3
// correct voting power after initialization, claim, or adjustment
DistributionRecord memory record = records[beneficiary]; uint256 newVotes = record.claimed >= record.total ? 0 : tokensToVotes(record.total - record.claimed); if (currentVotes > newVotes) {
DistributionRecord memory record = records[beneficiary]; uint256 newVotes = record.claimed >= record.total ? 0 : tokensToVotes(record.total - record.claimed); if (currentVotes > newVotes) {
15,003
12
// Get number of tokens currently belonging to given owner._owner address to get number of tokens currently belonging to the owner ofreturn number of tokens currently belonging to the owner of given address /
function balanceOf(address _owner) constant returns (uint256 balance) { return accounts [_owner]; }
function balanceOf(address _owner) constant returns (uint256 balance) { return accounts [_owner]; }
18,357
0
// _l1Bridge Address of the L1 standard bridge. _l2Contract Address of the corresponding L2 NFT contract. _name ERC721 name. _symbol ERC721 symbol. /
constructor( address _l1Bridge, address _l2Contract, string memory _name, string memory _symbol, string memory _baseTokenURI
constructor( address _l1Bridge, address _l2Contract, string memory _name, string memory _symbol, string memory _baseTokenURI
37,737
9
// trigger notification of withdrawal pid pid of the pool rewardAmountusers final rewards withdrawn /
event NotifyRewardAdded(
event NotifyRewardAdded(
24,132
8
// TODO/chain TODO/newBool TODO
function setIsEVM(string calldata chain, bool newBool) external;
function setIsEVM(string calldata chain, bool newBool) external;
2,448
70
// Used when multiple can call./
modifier onlyModules(bytes32 _moduleOne, bytes32 _moduleTwo) { string memory message = string(abi.encodePacked("only module ", _moduleOne.toString()," or ", _moduleTwo.toString()," can call this function")); require(msg.sender == getModule(_moduleOne) || msg.sender == getModule(_moduleTwo), message); _; }
modifier onlyModules(bytes32 _moduleOne, bytes32 _moduleTwo) { string memory message = string(abi.encodePacked("only module ", _moduleOne.toString()," or ", _moduleTwo.toString()," can call this function")); require(msg.sender == getModule(_moduleOne) || msg.sender == getModule(_moduleTwo), message); _; }
44,505
26
// Returns the address that signed a hashed message (`hash`) with`signature` or error string. This address can then be used for verification purposes. The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:this function rejects them by requiring the `s` value to be in the lowerhalf order, and the `v` value to be either 27 or 28. IMPORTANT: `hash` _must_ be the result of a hash operation for theverification to be secure: it is possible to craft signatures thatrecover to arbitrary addresses for non-hashed data. A safe way to ensurethis is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { // Check the signature length // - case 65: r,s,v signature (standard) // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._ if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else if (signature.length == 64) { bytes32 r; bytes32 vs; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) vs := mload(add(signature, 0x40)) } return tryRecover(hash, r, vs); } else { return (address(0), RecoverError.InvalidSignatureLength); } }
* be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { // Check the signature length // - case 65: r,s,v signature (standard) // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._ if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else if (signature.length == 64) { bytes32 r; bytes32 vs; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) vs := mload(add(signature, 0x40)) } return tryRecover(hash, r, vs); } else { return (address(0), RecoverError.InvalidSignatureLength); } }
21,735
173
// Events//Variables//Public Functions//Sends a cross domain message to the target messenger. _target Target contract address. _message Message to send to the target. _gasLimit Gas limit for the provided message. /
function sendMessage( address _target, bytes calldata _message, uint32 _gasLimit ) external;
function sendMessage( address _target, bytes calldata _message, uint32 _gasLimit ) external;
37,273
0
// decide if an upkeep is needed and return bool accordingly
return (shouldPerformUpkeep, bytesToSend);
return (shouldPerformUpkeep, bytesToSend);
14,176
2
// randomly set secretNumber with a value between 1 and 10
secretNumber = uint8(sha3(now, block.blockhash(block.number-1))) % 10 + 1;
secretNumber = uint8(sha3(now, block.blockhash(block.number-1))) % 10 + 1;
50,926
50
// Allows admin to launch a new ICO _startTimestamp Start timestamp in epochs _durationSeconds ICO time in seconds(1 day=246060) _coinsPerETH BST price in ETH(1 ETH = ? BST) _maxCap Max ETH capture in wei amount _minAmount Min ETH amount per user in wei amount _isPublic Boolean to represent that the ICO is public or not /
function adminAddICO( uint256 _startTimestamp, uint256 _durationSeconds, uint256 _coinsPerETH, uint256 _maxCap, uint256 _minAmount, uint[] _rewardHours, uint256[] _rewardPercents, bool _isPublic
function adminAddICO( uint256 _startTimestamp, uint256 _durationSeconds, uint256 _coinsPerETH, uint256 _maxCap, uint256 _minAmount, uint[] _rewardHours, uint256[] _rewardPercents, bool _isPublic
17,539
256
// SMMA filter with function: SMMA(i) = (SMMA(i-1)(n-1) + PRICE(i)) / n _prePrice PRICE[n-1] _price PRICE[n]return filtered price /
function smma(uint256 _prePrice, uint256 _price) internal pure returns (uint256) { return (_prePrice * (smmaPeriod - 1) + _price) / smmaPeriod; }
function smma(uint256 _prePrice, uint256 _price) internal pure returns (uint256) { return (_prePrice * (smmaPeriod - 1) + _price) / smmaPeriod; }
17,332
5
// pay the seller
_transferFrom(seller, buyer, _tokenId);
_transferFrom(seller, buyer, _tokenId);
39,527
320
// Initializes the contract in unpaused state. /
constructor() {
constructor() {
1,203
190
// Set base URI. /
function setBaseURI(string memory _baseURI) public onlyOwner { baseURI = _baseURI; }
function setBaseURI(string memory _baseURI) public onlyOwner { baseURI = _baseURI; }
49,859
119
// verify ownership
address tokenOwner = ownerOf[idList[i]]; if (tokenOwner != msg.sender || tokenOwner == BURN_ADDRESS) { revert Error_NotTokenOwner(); }
address tokenOwner = ownerOf[idList[i]]; if (tokenOwner != msg.sender || tokenOwner == BURN_ADDRESS) { revert Error_NotTokenOwner(); }
60,117
206
// Setup Functions/
bool public tradingEnabled; bool public whiteListTrading; address private _liquidityTokenAddress;
bool public tradingEnabled; bool public whiteListTrading; address private _liquidityTokenAddress;
13,630
2
// Integer division of two numbers truncating the quotient, reverts on division by zero./
function div(uint256 a, uint256 b) internal pure returns (uint256) {require(b > 0); uint256 c = a / b; // assert(a == b * c + a % b); return c;}
function div(uint256 a, uint256 b) internal pure returns (uint256) {require(b > 0); uint256 c = a / b; // assert(a == b * c + a % b); return c;}
29,870
9
// Claims reward for the sender account
function getReward() public nonReentrant updateReward(msg.sender) { uint256 reward = rewards[msg.sender]; if (reward > 0) { rewards[msg.sender] = 0; uint256 contractBalance = rewardToken.balanceOf(address(this)); if (contractBalance < reward) { reward = contractBalance; // Prevents contract from locking up } rewardToken.safeTransfer(msg.sender, reward); emit RewardPaid(msg.sender, reward); } }
function getReward() public nonReentrant updateReward(msg.sender) { uint256 reward = rewards[msg.sender]; if (reward > 0) { rewards[msg.sender] = 0; uint256 contractBalance = rewardToken.balanceOf(address(this)); if (contractBalance < reward) { reward = contractBalance; // Prevents contract from locking up } rewardToken.safeTransfer(msg.sender, reward); emit RewardPaid(msg.sender, reward); } }
8,177
44
// ICO Contract for the LBC crowdsale/
contract HLBICO is CappedTimedCrowdsale, RefundablePostDeliveryCrowdsale { using SafeMath for uint256; /* ** Global State */ bool public initialized; // default : false /* ** Addresses */ address public _deployingAddress; // should remain the same as deployer's address address public _whitelistingAddress; // should be oracle address public _reserveAddress; // should be deployer then humble reserve /* ** Events */ event InitializedContract(address indexed changerAddress, address indexed whitelistingAddress); event ChangedWhitelisterAddress(address indexed whitelisterAddress, address indexed changerAddress); event ChangedReserveAddress(address indexed reserveAddress, address indexed changerAddress); event ChangedDeployerAddress(address indexed deployerAddress, address indexed changerAddress); event BlacklistedAdded(address indexed account); event BlacklistedRemoved(address indexed account); event UpdatedCaps(uint256 newGoal, uint256 newCap, uint256 newTranche, uint256 newMaxInvest, uint256 newRate, uint256 newRateCoef); /* ** Attrs */ uint256 private _currentRate; uint256 private _rateCoef; mapping(address => bool) private _blacklistedAddrs; mapping(address => uint256) private _investmentAddrs; uint256 private _weiMaxInvest; uint256 private _etherTranche; uint256 private _currentWeiTranche; // Holds the current invested value for a tranche uint256 private _deliverToReserve; uint256 private _minimumInvest; /* * initialRateReceived : Number of token units a buyer gets per wei for the first investment slice. Should be 5000 (diving by 1000 for 3 decimals). * walletReceived : Wallet that will get the invested eth at the end of the crowdsale * tokenReceived : Address of the LBC token being sold * openingTimeReceived : Starting date of the ICO * closingtimeReceived : Ending date of the ICO * capReceived : Max amount of wei to be contributed * goalReceived : Funding goal * etherMaxInvestReceived : Maximum ether that can be invested */ constructor(uint256 initialRateReceived, uint256 rateCoefficientReceived, address payable walletReceived, LBCToken tokenReceived, uint256 openingTimeReceived, uint256 closingTimeReceived, uint256 capReceived, uint256 goalReceived) CrowdsaleMint(initialRateReceived, walletReceived, tokenReceived) TimedCrowdsale(openingTimeReceived, closingTimeReceived) CappedTimedCrowdsale(capReceived) RefundableCrowdsale(goalReceived) { _deployingAddress = msg.sender; _etherTranche = 250000000000000000000; // 300000€; For eth = 1200 € _weiMaxInvest = 8340000000000000000; // 10008€; for eth = 1200 € _currentRate = initialRateReceived; _rateCoef = rateCoefficientReceived; _currentWeiTranche = 0; _deliverToReserve = 0; _minimumInvest = 1000000000000000; // 1.20€; for eth = 1200€ } /* ** Initializes the contract address and affects addresses to their roles. */ function init( address whitelistingAddress, address reserveAddress ) public isNotInitialized onlyDeployingAddress { require(whitelistingAddress != address(0), "HLBICO: whitelistingAddress cannot be 0x"); require(reserveAddress != address(0), "HLBICO: reserveAddress cannot be 0x"); _whitelistingAddress = whitelistingAddress; _reserveAddress = reserveAddress; initialized = true; emit InitializedContract(_msgSender(), whitelistingAddress); } /** * @dev Returns the rate of tokens per wei at the present time and computes rate depending on tranche. * @param weiAmount The value in wei to be converted into tokens * @return The number of tokens a buyer gets per wei for a given tranche */ function _getCustomAmount(uint256 weiAmount) internal returns (uint256) { if (!isOpen()) { return 0; } uint256 calculatedAmount = 0; _currentWeiTranche = _currentWeiTranche.add(weiAmount); if (_currentWeiTranche > _etherTranche) { _currentWeiTranche = _currentWeiTranche.sub(_etherTranche); //If we updated the tranche manually to a smaller one uint256 manualSkew = weiAmount.sub(_currentWeiTranche); if (manualSkew >= 0) { calculatedAmount = calculatedAmount.add(weiAmount.sub(_currentWeiTranche).mul(rate())); _currentRate -= _rateCoef; // coefficient for 35 tokens reduction for each tranche calculatedAmount = calculatedAmount.add(_currentWeiTranche.mul(rate())); } //If there is a skew between invested wei and calculated wei for a tranche else { _currentRate -= _rateCoef; // coefficient for 35 tokens reduction for each tranche calculatedAmount = calculatedAmount.add(weiAmount.mul(rate())); } } else calculatedAmount = calculatedAmount.add(weiAmount.mul(rate())); uint256 participationAmount = calculatedAmount.mul(5).div(100); calculatedAmount = calculatedAmount.sub(participationAmount); _deliverToReserve = _deliverToReserve.add(participationAmount); return calculatedAmount; } /* ** Adjusts all parameters influenced by Ether value based on a percentage coefficient ** coef is based on 4 digits for decimal representation with 1 precision ** i.e : 934 -> 93.4%; 1278 -> 127.8% */ function adjustEtherValue(uint256 coef) public onlyDeployingAddress { require(coef > 0 && coef < 10000, "HLBICO: coef isn't within range of authorized values"); uint256 baseCoef = 1000; changeGoal(goal().mul(coef).div(1000)); changeCap(cap().mul(coef).div(1000)); _etherTranche = _etherTranche.mul(coef).div(1000); _weiMaxInvest = _weiMaxInvest.mul(coef).div(1000); if (coef > 1000) { coef = coef.sub(1000); _currentRate = _currentRate.sub(_currentRate.mul(coef).div(1000)); _rateCoef = _rateCoef.sub(_rateCoef.mul(coef).div(1000)); } else { coef = baseCoef.sub(coef); _currentRate = _currentRate.add(_currentRate.mul(coef).div(1000)); _rateCoef = _rateCoef.add(_rateCoef.mul(coef).div(1000)); } emit UpdatedCaps(goal(), cap(), _etherTranche, _weiMaxInvest, _currentRate, _rateCoef); } function rate() public view override returns (uint256) { return _currentRate; } function getNextRate() public view returns (uint256) { return _currentRate.sub(_rateCoef); } /* ** Changes the address of the token contract. Must only be callable by deployer */ function changeToken(LBCToken newToken) public onlyDeployingAddress { _changeToken(newToken); } /* ** Changes the address with whitelisting role and can only be called by deployer */ function changeWhitelister(address newWhitelisterAddress) public onlyDeployingAddress { _whitelistingAddress = newWhitelisterAddress; emit ChangedWhitelisterAddress(newWhitelisterAddress, _msgSender()); } /* ** Changes the address with deployer role and can only be called by deployer */ function changeDeployer(address newDeployerAddress) public onlyDeployingAddress { _deployingAddress = newDeployerAddress; emit ChangedDeployerAddress(_deployingAddress, _msgSender()); } /* ** Changes the address with pause role and can only be called by deployer */ function changeReserveAddress(address newReserveAddress) public onlyDeployingAddress { _reserveAddress = newReserveAddress; emit ChangedReserveAddress(newReserveAddress, _msgSender()); } /** * @dev Escrow finalization task, called when finalize() is called. */ function _finalization() override virtual internal { // Mints the 5% participation and sends it to humblereserve if (goalReached()) { _deliverTokens(_reserveAddress, _deliverToReserve); } super._finalization(); } /* ** Checks if an adress has been blacklisted before letting them withdraw their funds */ function withdrawTokens(address beneficiary) override virtual public { require(!isBlacklisted(beneficiary), "HLBICO: account is blacklisted"); super.withdrawTokens(beneficiary); } /** * @dev Overrides parent method taking into account variable rate. * @param weiAmount The value in wei to be converted into tokens * @return The number of tokens _weiAmount wei will buy at present time */ function _getTokenAmount(uint256 weiAmount) internal override returns (uint256) { return _getCustomAmount(weiAmount); } function _forwardFunds() internal override(CrowdsaleMint, RefundablePostDeliveryCrowdsale) { RefundablePostDeliveryCrowdsale._forwardFunds(); } function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal override(TimedCrowdsale, CappedTimedCrowdsale) view { require(weiAmount >= _minimumInvest, "HLBICO: Investment must be greater than or equal to 0.001 eth"); _dontExceedAmount(beneficiary, weiAmount); CappedTimedCrowdsale._preValidatePurchase(beneficiary, weiAmount); } function _postValidatePurchase(address beneficiary, uint256 weiAmount) internal override { require(beneficiary != address(0), "HLBICO: _postValidatePurchase benificiary is the zero address"); _investmentAddrs[beneficiary] = _investmentAddrs[beneficiary].add(weiAmount); } function _processPurchase(address beneficiary, uint256 tokenAmount) internal override(CrowdsaleMint, RefundablePostDeliveryCrowdsale) { RefundablePostDeliveryCrowdsale._processPurchase(beneficiary, tokenAmount); } function hasClosed() public view override(TimedCrowdsale, CappedTimedCrowdsale) returns (bool) { // solhint-disable-next-line not-rely-on-time return CappedTimedCrowdsale.hasClosed(); } function etherTranche() public view returns (uint256) { return _etherTranche; } function maxInvest() public view returns (uint256) { return _weiMaxInvest; } function addBlacklisted(address account) public onlyWhitelistingAddress { _addBlacklisted(account); } function removeBlacklisted(address account) public onlyWhitelistingAddress { _removeBlacklisted(account); } function isBlacklisted(address account) public view returns (bool) { require(account != address(0), "HLBICO: account is zero address"); return _blacklistedAddrs[account]; } function _addBlacklisted(address account) internal { require(!isBlacklisted(account), "HLBICO: account already blacklisted"); _blacklistedAddrs[account] = true; emit BlacklistedAdded(account); } function _removeBlacklisted(address account) internal { require(isBlacklisted(account), "HLBICO: account is not blacklisted"); _blacklistedAddrs[account] = true; emit BlacklistedRemoved(account); } function _dontExceedAmount(address beneficiary, uint256 weiAmount) internal view { require(_investmentAddrs[beneficiary].add(weiAmount) <= _weiMaxInvest, "HLBICO: Cannot invest more than KYC limit."); } modifier onlyWhitelistingAddress() { require(_msgSender() == _whitelistingAddress, "HLBICO: caller does not have the Whitelisted role"); _; } /* ** Checks if the contract hasn't already been initialized */ modifier isNotInitialized() { require(initialized == false, "HLBICO: contract is already initialized."); _; } /* ** Checks if the sender is the minter controller address */ modifier onlyDeployingAddress() { require(msg.sender == _deployingAddress, "HLBICO: only the deploying address can call this method."); _; } }
contract HLBICO is CappedTimedCrowdsale, RefundablePostDeliveryCrowdsale { using SafeMath for uint256; /* ** Global State */ bool public initialized; // default : false /* ** Addresses */ address public _deployingAddress; // should remain the same as deployer's address address public _whitelistingAddress; // should be oracle address public _reserveAddress; // should be deployer then humble reserve /* ** Events */ event InitializedContract(address indexed changerAddress, address indexed whitelistingAddress); event ChangedWhitelisterAddress(address indexed whitelisterAddress, address indexed changerAddress); event ChangedReserveAddress(address indexed reserveAddress, address indexed changerAddress); event ChangedDeployerAddress(address indexed deployerAddress, address indexed changerAddress); event BlacklistedAdded(address indexed account); event BlacklistedRemoved(address indexed account); event UpdatedCaps(uint256 newGoal, uint256 newCap, uint256 newTranche, uint256 newMaxInvest, uint256 newRate, uint256 newRateCoef); /* ** Attrs */ uint256 private _currentRate; uint256 private _rateCoef; mapping(address => bool) private _blacklistedAddrs; mapping(address => uint256) private _investmentAddrs; uint256 private _weiMaxInvest; uint256 private _etherTranche; uint256 private _currentWeiTranche; // Holds the current invested value for a tranche uint256 private _deliverToReserve; uint256 private _minimumInvest; /* * initialRateReceived : Number of token units a buyer gets per wei for the first investment slice. Should be 5000 (diving by 1000 for 3 decimals). * walletReceived : Wallet that will get the invested eth at the end of the crowdsale * tokenReceived : Address of the LBC token being sold * openingTimeReceived : Starting date of the ICO * closingtimeReceived : Ending date of the ICO * capReceived : Max amount of wei to be contributed * goalReceived : Funding goal * etherMaxInvestReceived : Maximum ether that can be invested */ constructor(uint256 initialRateReceived, uint256 rateCoefficientReceived, address payable walletReceived, LBCToken tokenReceived, uint256 openingTimeReceived, uint256 closingTimeReceived, uint256 capReceived, uint256 goalReceived) CrowdsaleMint(initialRateReceived, walletReceived, tokenReceived) TimedCrowdsale(openingTimeReceived, closingTimeReceived) CappedTimedCrowdsale(capReceived) RefundableCrowdsale(goalReceived) { _deployingAddress = msg.sender; _etherTranche = 250000000000000000000; // 300000€; For eth = 1200 € _weiMaxInvest = 8340000000000000000; // 10008€; for eth = 1200 € _currentRate = initialRateReceived; _rateCoef = rateCoefficientReceived; _currentWeiTranche = 0; _deliverToReserve = 0; _minimumInvest = 1000000000000000; // 1.20€; for eth = 1200€ } /* ** Initializes the contract address and affects addresses to their roles. */ function init( address whitelistingAddress, address reserveAddress ) public isNotInitialized onlyDeployingAddress { require(whitelistingAddress != address(0), "HLBICO: whitelistingAddress cannot be 0x"); require(reserveAddress != address(0), "HLBICO: reserveAddress cannot be 0x"); _whitelistingAddress = whitelistingAddress; _reserveAddress = reserveAddress; initialized = true; emit InitializedContract(_msgSender(), whitelistingAddress); } /** * @dev Returns the rate of tokens per wei at the present time and computes rate depending on tranche. * @param weiAmount The value in wei to be converted into tokens * @return The number of tokens a buyer gets per wei for a given tranche */ function _getCustomAmount(uint256 weiAmount) internal returns (uint256) { if (!isOpen()) { return 0; } uint256 calculatedAmount = 0; _currentWeiTranche = _currentWeiTranche.add(weiAmount); if (_currentWeiTranche > _etherTranche) { _currentWeiTranche = _currentWeiTranche.sub(_etherTranche); //If we updated the tranche manually to a smaller one uint256 manualSkew = weiAmount.sub(_currentWeiTranche); if (manualSkew >= 0) { calculatedAmount = calculatedAmount.add(weiAmount.sub(_currentWeiTranche).mul(rate())); _currentRate -= _rateCoef; // coefficient for 35 tokens reduction for each tranche calculatedAmount = calculatedAmount.add(_currentWeiTranche.mul(rate())); } //If there is a skew between invested wei and calculated wei for a tranche else { _currentRate -= _rateCoef; // coefficient for 35 tokens reduction for each tranche calculatedAmount = calculatedAmount.add(weiAmount.mul(rate())); } } else calculatedAmount = calculatedAmount.add(weiAmount.mul(rate())); uint256 participationAmount = calculatedAmount.mul(5).div(100); calculatedAmount = calculatedAmount.sub(participationAmount); _deliverToReserve = _deliverToReserve.add(participationAmount); return calculatedAmount; } /* ** Adjusts all parameters influenced by Ether value based on a percentage coefficient ** coef is based on 4 digits for decimal representation with 1 precision ** i.e : 934 -> 93.4%; 1278 -> 127.8% */ function adjustEtherValue(uint256 coef) public onlyDeployingAddress { require(coef > 0 && coef < 10000, "HLBICO: coef isn't within range of authorized values"); uint256 baseCoef = 1000; changeGoal(goal().mul(coef).div(1000)); changeCap(cap().mul(coef).div(1000)); _etherTranche = _etherTranche.mul(coef).div(1000); _weiMaxInvest = _weiMaxInvest.mul(coef).div(1000); if (coef > 1000) { coef = coef.sub(1000); _currentRate = _currentRate.sub(_currentRate.mul(coef).div(1000)); _rateCoef = _rateCoef.sub(_rateCoef.mul(coef).div(1000)); } else { coef = baseCoef.sub(coef); _currentRate = _currentRate.add(_currentRate.mul(coef).div(1000)); _rateCoef = _rateCoef.add(_rateCoef.mul(coef).div(1000)); } emit UpdatedCaps(goal(), cap(), _etherTranche, _weiMaxInvest, _currentRate, _rateCoef); } function rate() public view override returns (uint256) { return _currentRate; } function getNextRate() public view returns (uint256) { return _currentRate.sub(_rateCoef); } /* ** Changes the address of the token contract. Must only be callable by deployer */ function changeToken(LBCToken newToken) public onlyDeployingAddress { _changeToken(newToken); } /* ** Changes the address with whitelisting role and can only be called by deployer */ function changeWhitelister(address newWhitelisterAddress) public onlyDeployingAddress { _whitelistingAddress = newWhitelisterAddress; emit ChangedWhitelisterAddress(newWhitelisterAddress, _msgSender()); } /* ** Changes the address with deployer role and can only be called by deployer */ function changeDeployer(address newDeployerAddress) public onlyDeployingAddress { _deployingAddress = newDeployerAddress; emit ChangedDeployerAddress(_deployingAddress, _msgSender()); } /* ** Changes the address with pause role and can only be called by deployer */ function changeReserveAddress(address newReserveAddress) public onlyDeployingAddress { _reserveAddress = newReserveAddress; emit ChangedReserveAddress(newReserveAddress, _msgSender()); } /** * @dev Escrow finalization task, called when finalize() is called. */ function _finalization() override virtual internal { // Mints the 5% participation and sends it to humblereserve if (goalReached()) { _deliverTokens(_reserveAddress, _deliverToReserve); } super._finalization(); } /* ** Checks if an adress has been blacklisted before letting them withdraw their funds */ function withdrawTokens(address beneficiary) override virtual public { require(!isBlacklisted(beneficiary), "HLBICO: account is blacklisted"); super.withdrawTokens(beneficiary); } /** * @dev Overrides parent method taking into account variable rate. * @param weiAmount The value in wei to be converted into tokens * @return The number of tokens _weiAmount wei will buy at present time */ function _getTokenAmount(uint256 weiAmount) internal override returns (uint256) { return _getCustomAmount(weiAmount); } function _forwardFunds() internal override(CrowdsaleMint, RefundablePostDeliveryCrowdsale) { RefundablePostDeliveryCrowdsale._forwardFunds(); } function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal override(TimedCrowdsale, CappedTimedCrowdsale) view { require(weiAmount >= _minimumInvest, "HLBICO: Investment must be greater than or equal to 0.001 eth"); _dontExceedAmount(beneficiary, weiAmount); CappedTimedCrowdsale._preValidatePurchase(beneficiary, weiAmount); } function _postValidatePurchase(address beneficiary, uint256 weiAmount) internal override { require(beneficiary != address(0), "HLBICO: _postValidatePurchase benificiary is the zero address"); _investmentAddrs[beneficiary] = _investmentAddrs[beneficiary].add(weiAmount); } function _processPurchase(address beneficiary, uint256 tokenAmount) internal override(CrowdsaleMint, RefundablePostDeliveryCrowdsale) { RefundablePostDeliveryCrowdsale._processPurchase(beneficiary, tokenAmount); } function hasClosed() public view override(TimedCrowdsale, CappedTimedCrowdsale) returns (bool) { // solhint-disable-next-line not-rely-on-time return CappedTimedCrowdsale.hasClosed(); } function etherTranche() public view returns (uint256) { return _etherTranche; } function maxInvest() public view returns (uint256) { return _weiMaxInvest; } function addBlacklisted(address account) public onlyWhitelistingAddress { _addBlacklisted(account); } function removeBlacklisted(address account) public onlyWhitelistingAddress { _removeBlacklisted(account); } function isBlacklisted(address account) public view returns (bool) { require(account != address(0), "HLBICO: account is zero address"); return _blacklistedAddrs[account]; } function _addBlacklisted(address account) internal { require(!isBlacklisted(account), "HLBICO: account already blacklisted"); _blacklistedAddrs[account] = true; emit BlacklistedAdded(account); } function _removeBlacklisted(address account) internal { require(isBlacklisted(account), "HLBICO: account is not blacklisted"); _blacklistedAddrs[account] = true; emit BlacklistedRemoved(account); } function _dontExceedAmount(address beneficiary, uint256 weiAmount) internal view { require(_investmentAddrs[beneficiary].add(weiAmount) <= _weiMaxInvest, "HLBICO: Cannot invest more than KYC limit."); } modifier onlyWhitelistingAddress() { require(_msgSender() == _whitelistingAddress, "HLBICO: caller does not have the Whitelisted role"); _; } /* ** Checks if the contract hasn't already been initialized */ modifier isNotInitialized() { require(initialized == false, "HLBICO: contract is already initialized."); _; } /* ** Checks if the sender is the minter controller address */ modifier onlyDeployingAddress() { require(msg.sender == _deployingAddress, "HLBICO: only the deploying address can call this method."); _; } }
24,516
3
// This is the constructor. It runs only once, when the contract is created.
function MyCoin() public { minter = msg.sender; }
function MyCoin() public { minter = msg.sender; }
49,501
68
// Withdrawable token Token that can be the withdrawal. /
contract WithdrawableToken is BasicToken, Ownable { using SafeMath for uint256; bool public withdrawingFinished = false; event Withdraw(address _from, address _to, uint256 _value); event WithdrawFinished(); modifier canWithdraw() { require(!withdrawingFinished); _; } modifier hasWithdrawPermission() { require(msg.sender == owner); _; } /** * @dev Withdraw the amount of tokens to onwer. * @param _from address The address which owner want to withdraw tokens form. * @param _value uint256 the amount of tokens to be transferred. */ function withdraw(address _from, uint256 _value) public hasWithdrawPermission canWithdraw returns (bool) { require(_value <= balances[_from]); balances[_from] = balances[_from].sub(_value); balances[owner] = balances[owner].add(_value); emit Transfer(_from, owner, _value); emit Withdraw(_from, owner, _value); return true; } /** * @dev Withdraw the amount of tokens to another. * @param _from address The address which owner want to withdraw tokens from. * @param _to address The address which owner want to transfer to. * @param _value uint256 the amount of tokens to be transferred. */ function withdrawFrom(address _from, address _to, uint256 _value) public hasWithdrawPermission canWithdraw returns (bool) { require(_value <= balances[_from]); require(_to != address(0)); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(_from, _to, _value); emit Withdraw(_from, _to, _value); return true; } /** * @dev Function to stop withdrawing new tokens. * @return True if the operation was successful. */ function finishingWithdrawing() public onlyOwner canWithdraw returns (bool) { withdrawingFinished = true; emit WithdrawFinished(); return true; } }
contract WithdrawableToken is BasicToken, Ownable { using SafeMath for uint256; bool public withdrawingFinished = false; event Withdraw(address _from, address _to, uint256 _value); event WithdrawFinished(); modifier canWithdraw() { require(!withdrawingFinished); _; } modifier hasWithdrawPermission() { require(msg.sender == owner); _; } /** * @dev Withdraw the amount of tokens to onwer. * @param _from address The address which owner want to withdraw tokens form. * @param _value uint256 the amount of tokens to be transferred. */ function withdraw(address _from, uint256 _value) public hasWithdrawPermission canWithdraw returns (bool) { require(_value <= balances[_from]); balances[_from] = balances[_from].sub(_value); balances[owner] = balances[owner].add(_value); emit Transfer(_from, owner, _value); emit Withdraw(_from, owner, _value); return true; } /** * @dev Withdraw the amount of tokens to another. * @param _from address The address which owner want to withdraw tokens from. * @param _to address The address which owner want to transfer to. * @param _value uint256 the amount of tokens to be transferred. */ function withdrawFrom(address _from, address _to, uint256 _value) public hasWithdrawPermission canWithdraw returns (bool) { require(_value <= balances[_from]); require(_to != address(0)); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(_from, _to, _value); emit Withdraw(_from, _to, _value); return true; } /** * @dev Function to stop withdrawing new tokens. * @return True if the operation was successful. */ function finishingWithdrawing() public onlyOwner canWithdraw returns (bool) { withdrawingFinished = true; emit WithdrawFinished(); return true; } }
27,664
172
// Update dev address by the previous dev.
function dev(address _devaddr) public { require(msg.sender == devaddr, "dev: wut?"); devaddr = _devaddr; }
function dev(address _devaddr) public { require(msg.sender == devaddr, "dev: wut?"); devaddr = _devaddr; }
1,340
261
// Add the d command prior to any bits
if (uint8(input[idx + 1] & dCommandBit) > 0) { outputIdx = addOutput(output, outputIdx, bytes(" "), D_COMMANDS[uint8(input[idx])]); }
if (uint8(input[idx + 1] & dCommandBit) > 0) { outputIdx = addOutput(output, outputIdx, bytes(" "), D_COMMANDS[uint8(input[idx])]); }
19,719
22
// Moves `amount` tokens from the caller's account to `recipient`. Returns a boolean value indicating whether the operation succeeded.
* Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
* Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
31,190
73
// Event emitted when an initiative is completed /
event InitiativeCompleted(string indexed initiativeHash);
event InitiativeCompleted(string indexed initiativeHash);
51,661
9
// Withdraw ether from client's account and sent it to the client's address.May only be called by client._value value to withdraw (in Wei)return true if ether was successfully withdrawn, false otherwise /
function withdraw (uint256 _value)
function withdraw (uint256 _value)
37,533
78
// Increment the array (cannot overflow as index starts at 0).
unchecked { ++i; }
unchecked { ++i; }
20,943
35
// We keep the unlock data in a separate mapping to allow channel data structures to be removed when settling uncooperatively. If there are locked pending transfers, we need to store data needed to unlock them at a later time. The key is `keccak256(uint256 channel_identifier, address participant, address partner)` Where `participant` is the participant that sent the pending transfers We need `partner` for knowing where to send the claimable tokens
mapping(bytes32 => UnlockData) private unlock_identifier_to_unlock_data;
mapping(bytes32 => UnlockData) private unlock_identifier_to_unlock_data;
68,176
57
// `msg.sender` approves `_spender` to spend `_amount` tokens on/its behalf. This is a modified version of the ERC20 approve function/to be a little bit safer/_spender The address of the account able to transfer the tokens/_amount The amount of tokens to be approved for transfer/ return True if the approval was successful
function approve(address _spender, uint256 _amount) returns (bool success) { require(transfersEnabled); // 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/20#issuecomment-263524729 require((_amount == 0) || (allowed[msg.sender][_spender] == 0)); // Alerts the token controller of the approve function call if (isContract(controller)) { require(TokenController(controller).onApprove(msg.sender, _spender, _amount)); } allowed[msg.sender][_spender] = _amount; Approval(msg.sender, _spender, _amount); return true; }
function approve(address _spender, uint256 _amount) returns (bool success) { require(transfersEnabled); // 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/20#issuecomment-263524729 require((_amount == 0) || (allowed[msg.sender][_spender] == 0)); // Alerts the token controller of the approve function call if (isContract(controller)) { require(TokenController(controller).onApprove(msg.sender, _spender, _amount)); } allowed[msg.sender][_spender] = _amount; Approval(msg.sender, _spender, _amount); return true; }
33,781
126
// Checks if transfer passes transfer rules.from The address to transfer from.to The address to send tokens to.value The amount of tokens to send./
function authorize( address from, address to, uint256 value ) public view returns (bool)
function authorize( address from, address to, uint256 value ) public view returns (bool)
3,026
12
// SUPPLY CONTROL DATA
address public supplyController;
address public supplyController;
1,073
86
// @notify View function meant to return whether a decrease in the debt ceiling is currently allowed/
function allowsDecrease(uint256 redemptionRate, uint256 currentDebtCeiling, uint256 updatedCeiling) public view returns (bool allowDecrease) { allowDecrease = either(redemptionRate >= RAY, both(redemptionRate < RAY, blockDecreaseWhenDevalue == 0)); allowDecrease = both(currentDebtCeiling >= updatedCeiling, allowDecrease); }
function allowsDecrease(uint256 redemptionRate, uint256 currentDebtCeiling, uint256 updatedCeiling) public view returns (bool allowDecrease) { allowDecrease = either(redemptionRate >= RAY, both(redemptionRate < RAY, blockDecreaseWhenDevalue == 0)); allowDecrease = both(currentDebtCeiling >= updatedCeiling, allowDecrease); }
53,736
237
// Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} isused, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1. Calling conditions: - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`.- When `from` is zero, the tokens will be minted for `to`.- When `to` is zero, ``from``'s tokens will be burned.- `from` and `to` are never both zero.- `batchSize` is non-zero. To learn more about hooks, head to xref:ROOT:extending-contracts.adocusing-hooks[Using Hooks]. /
function _beforeTokenTransfer( address from, address to, uint256 /* firstTokenId */, uint256 batchSize ) internal virtual { if (batchSize > 1) { if (from != address(0)) { _balances[from] -= batchSize; }
function _beforeTokenTransfer( address from, address to, uint256 /* firstTokenId */, uint256 batchSize ) internal virtual { if (batchSize > 1) { if (from != address(0)) { _balances[from] -= batchSize; }
34,388
21
// Function to permit the claiming of an asset to a reserved address./to The intended recipient (reserved address) of the ERC1155 tokens./assetIds The array of IDs of the asset tokens./assetValues The amounts of each token ID to transfer./proof The proof submitted for verification./salt The salt submitted for verification.
function claimAssets( address to, uint256[] calldata assetIds, uint256[] calldata assetValues, bytes32[] calldata proof, bytes32 salt
function claimAssets( address to, uint256[] calldata assetIds, uint256[] calldata assetValues, bytes32[] calldata proof, bytes32 salt
62,880
596
// Coinvise premium. If premium rate is 0.2%, is would be stored as 0.210^decimals = 20
uint256 public premiumPercentage; uint256 public premiumPercentageDecimals; uint256 public nftListingFee;
uint256 public premiumPercentage; uint256 public premiumPercentageDecimals; uint256 public nftListingFee;
45,387
113
// increase new representative
uint32 dstRepNum = numCheckpoints[dstRep]; uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0; uint256 dstRepNew = dstRepOld.add(amount); _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);
uint32 dstRepNum = numCheckpoints[dstRep]; uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0; uint256 dstRepNew = dstRepOld.add(amount); _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);
13,387
108
// this is mooniswap
IMooniswap lpToken = IMooniswap(lpTokensInfo[_pid].lpToken); IERC20[] memory t = lpToken.getTokens(); return (address(t[0]), address(t[1]));
IMooniswap lpToken = IMooniswap(lpTokensInfo[_pid].lpToken); IERC20[] memory t = lpToken.getTokens(); return (address(t[0]), address(t[1]));
34,522
42
// restrict function to be callable when token is active /
modifier activated() { require(active == true); _; }
modifier activated() { require(active == true); _; }
15,538
44
// retrieve ref. bonus
_dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0;
_dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0;
43,109
42
// This method will return the release time for upcoming quarter/
function nextReleaseTime() external view returns(uint256 time) { time = quarterSchedule[lastQuarter]; }
function nextReleaseTime() external view returns(uint256 time) { time = quarterSchedule[lastQuarter]; }
15,498
16
// Reject an existing administrator. _admin The administrator's address. /
function reject(address _admin) external onlyOwner { AdminInfo storage adminInfo = adminTable[_admin]; require(adminArray.length > adminInfo.index, "administrator is already rejected"); require(_admin == adminArray[adminInfo.index], "administrator is already rejected"); // at this point we know that adminArray.length > adminInfo.index >= 0 address lastAdmin = adminArray[adminArray.length - 1]; // will never underflow adminTable[lastAdmin].index = adminInfo.index; adminArray[adminInfo.index] = lastAdmin; adminArray.length -= 1; // will never underflow delete adminTable[_admin]; emit AdminRejected(_admin); }
function reject(address _admin) external onlyOwner { AdminInfo storage adminInfo = adminTable[_admin]; require(adminArray.length > adminInfo.index, "administrator is already rejected"); require(_admin == adminArray[adminInfo.index], "administrator is already rejected"); // at this point we know that adminArray.length > adminInfo.index >= 0 address lastAdmin = adminArray[adminArray.length - 1]; // will never underflow adminTable[lastAdmin].index = adminInfo.index; adminArray[adminInfo.index] = lastAdmin; adminArray.length -= 1; // will never underflow delete adminTable[_admin]; emit AdminRejected(_admin); }
15,967
76
// Participant must put up the entry fee.
require(msg.value >= _contestToEnter.entryFee);
require(msg.value >= _contestToEnter.entryFee);
48,470
214
// Sanity check: Ensure we were able to retrieve sufficent want from strategy positions If we end up with less than the amount requested, make sure it does not deviate beyond a maximum threshold
if (_postWithdraw < _amount) { uint256 diff = _diff(_amount, _postWithdraw);
if (_postWithdraw < _amount) { uint256 diff = _diff(_amount, _postWithdraw);
10,625
108
// remove an address from the frozenlist _operator addressreturn true if the address was removed from the frozenlist,false if the address wasn't in the frozenlist in the first place /
function removeAddressFromFrozenlist(address _operator) public onlyIssuer { removeRole(_operator, ROLE_FROZENLIST); }
function removeAddressFromFrozenlist(address _operator) public onlyIssuer { removeRole(_operator, ROLE_FROZENLIST); }
57,823
20
// Get airline details return Airline with the provided address /
function getAirlineName(address airline) external view returns(string memory) { return airlines[airline].name; }
function getAirlineName(address airline) external view returns(string memory) { return airlines[airline].name; }
39,823
147
// Approve spender to transfer tokens and then execute a callback on recipient. spender The address allowed to transfer to value The amount allowed to be transferredreturn A boolean that indicates if the operation was successful. /
function approveAndCall(address spender, uint256 value) public override returns (bool) { return approveAndCall(spender, value, ""); }
function approveAndCall(address spender, uint256 value) public override returns (bool) { return approveAndCall(spender, value, ""); }
6,441
284
// providers must provide LBT price caluculator and ERC20 price oracle. /
function setProvider( bytes32 erc20PoolID, address oracleAddress, address
function setProvider( bytes32 erc20PoolID, address oracleAddress, address
13,266
22
// Fixed crowdsale pricing - everybody gets the same price. /
contract PricingStrategy is HasNoEther { using SafeMath for uint; /* How many weis one token costs */ uint256 public oneTokenInWei; address public crowdsaleAddress; function PricingStrategy(address _crowdsale) { crowdsaleAddress = _crowdsale; } modifier onlyCrowdsale() { require(msg.sender == crowdsaleAddress); _; } /** * Calculate the current price for buy in amount. * */ function calculatePrice(uint256 _value, uint256 _decimals) public constant returns (uint) { uint256 multiplier = 10 ** _decimals; uint256 weiAmount = _value.mul(multiplier); uint256 tokens = weiAmount.div(oneTokenInWei); return tokens; } function setTokenPriceInWei(uint _oneTokenInWei) onlyCrowdsale public returns (bool) { oneTokenInWei = _oneTokenInWei; return true; } }
contract PricingStrategy is HasNoEther { using SafeMath for uint; /* How many weis one token costs */ uint256 public oneTokenInWei; address public crowdsaleAddress; function PricingStrategy(address _crowdsale) { crowdsaleAddress = _crowdsale; } modifier onlyCrowdsale() { require(msg.sender == crowdsaleAddress); _; } /** * Calculate the current price for buy in amount. * */ function calculatePrice(uint256 _value, uint256 _decimals) public constant returns (uint) { uint256 multiplier = 10 ** _decimals; uint256 weiAmount = _value.mul(multiplier); uint256 tokens = weiAmount.div(oneTokenInWei); return tokens; } function setTokenPriceInWei(uint _oneTokenInWei) onlyCrowdsale public returns (bool) { oneTokenInWei = _oneTokenInWei; return true; } }
39,214
19
// Distribute reward amount equally across the first staker's tokens
if (dao.rewardPerToken > 0) { user.pendingRewards = dao.rewardPerToken; dao.rewardPerToken = _calculateRewardPerToken( 0, dao.rewardPerToken, _amount ); }
if (dao.rewardPerToken > 0) { user.pendingRewards = dao.rewardPerToken; dao.rewardPerToken = _calculateRewardPerToken( 0, dao.rewardPerToken, _amount ); }
4,745
183
// ensures transfer of tokens, taking into account that some ERC-20 implementations don't return true on success but revert on failure instead _token the token to transfer_fromthe address to transfer the tokens from_tothe address to transfer the tokens to_amountthe amount to transfer/
function ensureTransferFrom(IERC20Token _token, address _from, address _to, uint256 _amount) private { // We must assume that functions `transfer` and `transferFrom` do not return anything, // because not all tokens abide the requirement of the ERC20 standard to return success or failure. // This is because in the current compiler version, the calling contract can handle more returned data than expected but not less. // This may change in the future, so that the calling contract will revert if the size of the data is not exactly what it expects. uint256 prevBalance = _token.balanceOf(_to); if (_from == address(this)) INonStandardERC20(_token).transfer(_to, _amount); else INonStandardERC20(_token).transferFrom(_from, _to, _amount); uint256 postBalance = _token.balanceOf(_to); require(postBalance > prevBalance); }
function ensureTransferFrom(IERC20Token _token, address _from, address _to, uint256 _amount) private { // We must assume that functions `transfer` and `transferFrom` do not return anything, // because not all tokens abide the requirement of the ERC20 standard to return success or failure. // This is because in the current compiler version, the calling contract can handle more returned data than expected but not less. // This may change in the future, so that the calling contract will revert if the size of the data is not exactly what it expects. uint256 prevBalance = _token.balanceOf(_to); if (_from == address(this)) INonStandardERC20(_token).transfer(_to, _amount); else INonStandardERC20(_token).transferFrom(_from, _to, _amount); uint256 postBalance = _token.balanceOf(_to); require(postBalance > prevBalance); }
20,386
6
// the duration. after this period all tokens will have been unlocked
uint256 public duration;
uint256 public duration;
16,276
0
// stores mapping of addresses
mapping(address => uint) public balanceReceived;
mapping(address => uint) public balanceReceived;
13,098
33
// claim phase 2 jackpot by phase 2 winner /
function claimPhase2Jackpot() public whenNotPaused onlyPhase2 onlyPhase2Revealed onlyPhase2Winner(phase2WinnerTokenID)
function claimPhase2Jackpot() public whenNotPaused onlyPhase2 onlyPhase2Revealed onlyPhase2Winner(phase2WinnerTokenID)
58,756
16
// - both parties can {lock} for `resolver`. /receiver The account that receives funds./resolver The account that unlock funds./token The asset used for funds (note: NFT not supported in BentoBox)./value The amount of funds (note: locker converts to 'shares')./termination Unix time upon which `depositor` can claim back funds./wrapBento If 'false', raw ERC-20 is assumed, otherwise, BentoBox 'shares'./details Describes context of escrow - stamped into event.
function depositBento( address receiver, address resolver, address token, uint256 value, uint256 termination, bool wrapBento, string memory details ) public payable returns (uint256 registration) { require(resolvers[resolver].active, "resolver not active");
function depositBento( address receiver, address resolver, address token, uint256 value, uint256 termination, bool wrapBento, string memory details ) public payable returns (uint256 registration) { require(resolvers[resolver].active, "resolver not active");
16,322
47
// Force withdraw all msg.sender's CRCL token to recipient's ERC20 token.The function acknowledges the request and records the request time.
* Emits a {Withdraw} event indicating the amount withdrawn. */ function forceWithdraw(address recipient) public withdrawRequested pastTimeLock returns (bool) { require(_withdraw(_msgSender(), recipient, _balances[_msgSender()]), "CRCL: force withdraw error"); setScheduleTime(_msgSender(), 0); return true; }
* Emits a {Withdraw} event indicating the amount withdrawn. */ function forceWithdraw(address recipient) public withdrawRequested pastTimeLock returns (bool) { require(_withdraw(_msgSender(), recipient, _balances[_msgSender()]), "CRCL: force withdraw error"); setScheduleTime(_msgSender(), 0); return true; }
39,349
99
// All reasons being used means the request can't be challenged again, so we can update its status.
submission.status = Status.None; submission.registered = true; submission.submissionTime = uint64(now); request.resolved = true;
submission.status = Status.None; submission.registered = true; submission.submissionTime = uint64(now); request.resolved = true;
13,785