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
122
// check to see if any _src tokens are left over after exchange
tokensLeft = getBalance(_exData.srcAddr);
tokensLeft = getBalance(_exData.srcAddr);
2,312
0
// ERC20 Token under lockable functionality/
HiblocksToken private _token;
HiblocksToken private _token;
45,006
29
// A generic interface for a contract which properly accepts ERC721 tokens./SolDAO (https:github.com/Sol-DAO/solbase/blob/main/src/tokens/ERC721.sol)/Modified from Solmate (https:github.com/transmissions11/solmate/blob/main/src/tokens/ERC721.sol)
abstract contract ERC721TokenReceiver { function onERC721Received(address, address, uint256, bytes calldata) external virtual returns (bytes4) { return ERC721TokenReceiver.onERC721Received.selector; } }
abstract contract ERC721TokenReceiver { function onERC721Received(address, address, uint256, bytes calldata) external virtual returns (bytes4) { return ERC721TokenReceiver.onERC721Received.selector; } }
22,019
97
// @solidity memory-safe-assembly
assembly { ptr := add(buffer, add(32, length)) }
assembly { ptr := add(buffer, add(32, length)) }
460
22
// Mapping gift type to gift limit.
mapping(uint256 => uint256) private giftTypeToGiftLimit;
mapping(uint256 => uint256) private giftTypeToGiftLimit;
35,423
10
// Pull `quoteToken` from the caller amount The requested amount to repay /
function repayQuoteToken(uint256 amount) external onlyElevatedAccess { emit RepayToken(address(quoteToken), amount); quoteToken.safeTransferFrom(msg.sender, address(this), amount); treasuryReservesVault.repay(quoteToken, amount, address(this)); }
function repayQuoteToken(uint256 amount) external onlyElevatedAccess { emit RepayToken(address(quoteToken), amount); quoteToken.safeTransferFrom(msg.sender, address(this), amount); treasuryReservesVault.repay(quoteToken, amount, address(this)); }
2,321
13
// hash together the contract addresses
bytes32 data = keccak256(abi.encodePacked(wrappedPosition, pool));
bytes32 data = keccak256(abi.encodePacked(wrappedPosition, pool));
64,826
87
// Increase the allowance by a given amount spender Spender's address addedValueAmount of increase in allowancereturn True if successful /
function increaseAllowance(address spender, uint256 addedValue) external returns (bool)
function increaseAllowance(address spender, uint256 addedValue) external returns (bool)
3,078
18
// Allow a user to migrate their stake to a new PremiaFeeDiscount contract (If a new contract has been set),/ while preserving same lockup expiration date
function migrateStake() external nonReentrant { require(address(newContract) != address(0), "Migration disabled"); UserInfo memory user = userInfo[msg.sender]; require(user.balance > 0, "No stake"); delete userInfo[msg.sender]; xPremia.safeIncreaseAllowance(address(newContract), user.balance); newContract.migrate(msg.sender, user.balance, user.stakePeriod, user.lockedUntil); emit StakeMigrated(msg.sender, address(newContract), user.balance, user.stakePeriod, user.lockedUntil); }
function migrateStake() external nonReentrant { require(address(newContract) != address(0), "Migration disabled"); UserInfo memory user = userInfo[msg.sender]; require(user.balance > 0, "No stake"); delete userInfo[msg.sender]; xPremia.safeIncreaseAllowance(address(newContract), user.balance); newContract.migrate(msg.sender, user.balance, user.stakePeriod, user.lockedUntil); emit StakeMigrated(msg.sender, address(newContract), user.balance, user.stakePeriod, user.lockedUntil); }
46,125
86
// ~~~>
receive() external payable { emit Received(msg.sender, msg.value); }
receive() external payable { emit Received(msg.sender, msg.value); }
41,542
169
// james foley http:github.com/realisation/selectively deposit any supported stablecoin flavor into the contract in return for corresponding amount of component tokens/_derivatives an array containing the addresses of the flavors being deposited into/_amounts an array containing the values of the flavors you wish to deposit into the contract. each amount should have the same index as the flavor it is meant to deposit/_minComponents minimum acceptable amount of components/_deadline deadline for tx/ return componentsToMint_ the amount of components to mint for the deposited stablecoin flavors
function selectiveDeposit ( address[] calldata _derivatives, uint[] calldata _amounts, uint _minComponents, uint _deadline ) external deadline(_deadline) transactable nonReentrant returns ( uint componentsMinted_
function selectiveDeposit ( address[] calldata _derivatives, uint[] calldata _amounts, uint _minComponents, uint _deadline ) external deadline(_deadline) transactable nonReentrant returns ( uint componentsMinted_
15,443
106
// addresses are "0x" followed by 20 bytes of data which take up 2 characters each
bytes memory result = new bytes(42);
bytes memory result = new bytes(42);
1,268
40
// Constructor sets the original owner of the contract and whether or not it is one time transferable.
constructor(address payable _account_, bool _transferable_) internal { _owner = _account_; _isTransferable = _transferable_; // Emit the LockedOwnership event if no longer transferable. if (!_isTransferable) { emit LockedOwnership(_account_); } emit TransferredOwnership(address(0), _account_); }
constructor(address payable _account_, bool _transferable_) internal { _owner = _account_; _isTransferable = _transferable_; // Emit the LockedOwnership event if no longer transferable. if (!_isTransferable) { emit LockedOwnership(_account_); } emit TransferredOwnership(address(0), _account_); }
18,770
58
// Transfer tokens from ICO address to another address._to The address to transfer to._value The amount to be transferred./
function transferFromIco(address _to, uint256 _value) public onlyIco returns (bool) { return super.transfer(_to, _value); }
function transferFromIco(address _to, uint256 _value) public onlyIco returns (bool) { return super.transfer(_to, _value); }
51,816
103
// RLPItem conversions into data types / returns raw rlp encoding in bytes
function toRlpBytes(RLPItem memory item) internal pure returns (bytes memory)
function toRlpBytes(RLPItem memory item) internal pure returns (bytes memory)
12,582
8
// initialClass.push(newClass);
numClasses++;
numClasses++;
30,827
122
// if any of these checks fails then arrays are not equal
if iszero(eq(mload(mc), mload(cc))) {
if iszero(eq(mload(mc), mload(cc))) {
31,870
377
// Holds number & validity of tokens locked for a given reason for a specified address /
mapping(address => mapping(bytes32 => LockToken)) public locked;
mapping(address => mapping(bytes32 => LockToken)) public locked;
28,792
62
// try to initialize an epoch. if it can't it fails if it fails either user either a Swapp account will init not init epochs
if (lastInitializedEpoch < epochId) { _initEpoch(epochId); }
if (lastInitializedEpoch < epochId) { _initEpoch(epochId); }
58,580
21
// Get Balance
function getBalance() external view onlyOwner returns (uint256) { return address(this).balance; }
function getBalance() external view onlyOwner returns (uint256) { return address(this).balance; }
21,458
1
// Returns true if a `leaf` can be proved to be a part of a Merkle treedefined by `root`. For this, a `proof` must be provided, containingsibling hashes on the branch from the leaf to the root of the tree. Eachpair of leaves and each pair of pre-images are assumed to be sorted. /
function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) { return processProof(proof, leaf) == root; }
function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) { return processProof(proof, leaf) == root; }
752
192
// WETH-specific functions.
function deposit() external payable; function withdraw(uint amount) external;
function deposit() external payable; function withdraw(uint amount) external;
27,807
63
// Represents a receipt token. The token is fully compliant with the ERC20 interface. The token can be minted or burnt by whitelisted addresses only. Only the owner is allowed to enable/disable addresses. /
contract ReceiptToken is Mintable { /** * @notice Constructor. * @param newOwner The owner of the smart contract. */ constructor (address newOwner, uint256 initialMaxSupply) Mintable(newOwner, "Fractal", "Fractal Protocol Vault Token", 6, 0) { maxSupply = initialMaxSupply; } }
contract ReceiptToken is Mintable { /** * @notice Constructor. * @param newOwner The owner of the smart contract. */ constructor (address newOwner, uint256 initialMaxSupply) Mintable(newOwner, "Fractal", "Fractal Protocol Vault Token", 6, 0) { maxSupply = initialMaxSupply; } }
50,182
182
// burn can only be called by the tokens' associated Gateway/ contract. See Gateway's burn functions instead.
function burn(address _from, uint256 _amount) public onlyOwner { _burn(_from, _amount); }
function burn(address _from, uint256 _amount) public onlyOwner { _burn(_from, _amount); }
11,428
0
// This mapping allows whitelisted addresses to claim on behalf of others useful for contracts that hold tokens to be rewarded but don't have any native logic to claim Liquidity Mining rewards
mapping(address => address) internal _authorizedClaimers;
mapping(address => address) internal _authorizedClaimers;
32,739
3
// Emitted when ERC20 tokens are withdrawn from this address.withdrawer Address that triggered the withdrawal. recipientAddress that received the withdrawal. assetAddress of the token being withdrawn. id Token ID being withdrawn. /
event WithdrewERC721(
event WithdrewERC721(
10,561
66
// add tokens
total_supply = total_supply.add(tokens); user.tokens = user.tokens.add(tokens);
total_supply = total_supply.add(tokens); user.tokens = user.tokens.add(tokens);
63,681
11
// Constructor
constructor() { acceptedToken = IERC20(token_addr); }
constructor() { acceptedToken = IERC20(token_addr); }
51,652
163
// 加入回答列表
answerList[_taskIndex].push(answer);
answerList[_taskIndex].push(answer);
51,027
63
// fromToken Address of the source token fromAmount Amount of source tokens to be swapped toAmount Minimum destination token amount expected out of this swap expectedAmount Expected amount of destination tokens without slippage beneficiary Beneficiary address0 then 100% will be transferred to beneficiary. Pass 10000 for 100% path Route to be taken for this swap to take place /
struct SellData { address fromToken; uint256 fromAmount; uint256 toAmount; uint256 expectedAmount; address payable beneficiary; Utils.Path[] path; address payable partner; uint256 feePercent; bytes permit; uint256 deadline; bytes16 uuid; }
struct SellData { address fromToken; uint256 fromAmount; uint256 toAmount; uint256 expectedAmount; address payable beneficiary; Utils.Path[] path; address payable partner; uint256 feePercent; bytes permit; uint256 deadline; bytes16 uuid; }
3,629
4
// Get betting odds.fund1Bank fund bank of condition's outcome 1fund2Bank fund bank of condition's outcome 2amount amount of tokens to betmargin bookmaker commissionmultiplier decimal unit representationreturn betting odds value /
function _getOddsFromBanks( uint256 fund1Bank, uint256 fund2Bank, uint256 amount, uint256 margin, uint256 multiplier
function _getOddsFromBanks( uint256 fund1Bank, uint256 fund2Bank, uint256 amount, uint256 margin, uint256 multiplier
8,228
14
// fallback方法,如果用户未在转账data中添加数据,默认是走这个方法
function () payable public { require(!finalised); // 判断是否在项目规定的时间范围内 require(block.timestamp >= startTime); require(block.timestamp <= endTime); // 判断硬顶 require(ethRaised < hardCap); // 达到最低捐赠额度才能继续,否则失败 require(msg.value >= minimumDonation); uint256 etherValue = msg.value; // 边界条件,未超过部分的ETH正常收纳,超过的部分退回给用户 if (ethRaised + etherValue > hardCap){ etherValue = hardCap - ethRaised; // 超过的部分退回给用户 assert(msg.value > etherValue); msg.sender.transfer(msg.value - etherValue); } // 转移ETH到指定ETH存币地址 ethFundAddress.transfer(etherValue); donationCount += 1; ethRaised += etherValue; }
function () payable public { require(!finalised); // 判断是否在项目规定的时间范围内 require(block.timestamp >= startTime); require(block.timestamp <= endTime); // 判断硬顶 require(ethRaised < hardCap); // 达到最低捐赠额度才能继续,否则失败 require(msg.value >= minimumDonation); uint256 etherValue = msg.value; // 边界条件,未超过部分的ETH正常收纳,超过的部分退回给用户 if (ethRaised + etherValue > hardCap){ etherValue = hardCap - ethRaised; // 超过的部分退回给用户 assert(msg.value > etherValue); msg.sender.transfer(msg.value - etherValue); } // 转移ETH到指定ETH存币地址 ethFundAddress.transfer(etherValue); donationCount += 1; ethRaised += etherValue; }
34,066
12
// initiate the sale process
if( state != State.OWNED ) return false; prospectiveSale = ProspectiveSale( _buyer, _salePrice, _exchangeRate ); state = State.SALE_INITIATED; return true;
if( state != State.OWNED ) return false; prospectiveSale = ProspectiveSale( _buyer, _salePrice, _exchangeRate ); state = State.SALE_INITIATED; return true;
40,719
2
// Override premiaOption contract into tx origin
if (_account == premiaOption) { _account = tx.origin; }
if (_account == premiaOption) { _account = tx.origin; }
38,124
234
// Burn this much token
IToken(tokenAddress).burnFrom(msg.sender, currentTokenCost()); return mintInternal();
IToken(tokenAddress).burnFrom(msg.sender, currentTokenCost()); return mintInternal();
48,866
0
// Constructor. Emits the `MagicValues` event. Emits the `Paused` event. payoutWallet_ the payout wallet. skusCapacity the cap for the number of managed SKUs. tokensPerSkuCapacity the cap for the number of tokens managed per SKU. /
constructor( address payoutWallet_, uint256 skusCapacity, uint256 tokensPerSkuCapacity
constructor( address payoutWallet_, uint256 skusCapacity, uint256 tokensPerSkuCapacity
15,062
0
// medication contract constructor (relation with regulator and pharmacy)
constructor(address _pharmacy) public { regulatorAddr = msg.sender; last_update_addr = msg.sender; pharmacyAddr = _pharmacy; }
constructor(address _pharmacy) public { regulatorAddr = msg.sender; last_update_addr = msg.sender; pharmacyAddr = _pharmacy; }
32,518
140
// requirement below is satisfied by statements aboverequire(pos == 0 || isOfferSorted(pos));
if (pos != 0) { //offers[id] is not the highest offer
if (pos != 0) { //offers[id] is not the highest offer
16,688
152
// The amount of cards in this machine.
uint256 public cardAmount; uint256 private _salt; uint256 public shuffleCount = 10;
uint256 public cardAmount; uint256 private _salt; uint256 public shuffleCount = 10;
33,093
0
// Contract owner address /
address public contractOwner;
address public contractOwner;
34,452
93
// Allow a user to deposit underlying tokens and mint the corresponding number of wrapped tokens. /
function depositFor(address account, uint256 amount) public virtual returns (bool) { SafeERC20.safeTransferFrom(underlying, _msgSender(), address(this), amount); _mint(account, amount); return true; }
function depositFor(address account, uint256 amount) public virtual returns (bool) { SafeERC20.safeTransferFrom(underlying, _msgSender(), address(this), amount); _mint(account, amount); return true; }
34,897
119
// Register to the Game
ids[sum_players]=msg.sender; // id -> address id[msg.sender]=sum_players; // address -> id parent[msg.sender]=_parent; // what is my parent? sum_players+=1;
ids[sum_players]=msg.sender; // id -> address id[msg.sender]=sum_players; // address -> id parent[msg.sender]=_parent; // what is my parent? sum_players+=1;
19,134
23
// Internal fucntions // Get price from ChainLink aggregator The ChainLink aggregator to get the price ofreturn The price /
function getPriceFromChainlink(AggregatorV3Interface aggregator) internal view returns (uint) { ( , int price, , , ) = aggregator.latestRoundData(); require(price > 0, "invalid price"); // Extend the decimals to 1e18. return mul_(uint(price), 10**(18 - uint(aggregator.decimals()))); }
function getPriceFromChainlink(AggregatorV3Interface aggregator) internal view returns (uint) { ( , int price, , , ) = aggregator.latestRoundData(); require(price > 0, "invalid price"); // Extend the decimals to 1e18. return mul_(uint(price), 10**(18 - uint(aggregator.decimals()))); }
11,470
59
// Throws if called by any account other than the registryAdmin. /
modifier onlyRegistryAdmin() { require(isRegistryAdmin(), "WithClaimableRegistryManagement: caller is not the registryAdmin"); _; }
modifier onlyRegistryAdmin() { require(isRegistryAdmin(), "WithClaimableRegistryManagement: caller is not the registryAdmin"); _; }
7,183
5
// Gets generator of G1 group.Taken from go-ethereum/crypto/bn256/cloudflare/curve.go /
uint256 constant g1x = 1; uint256 constant g1y = 2;
uint256 constant g1x = 1; uint256 constant g1y = 2;
7,288
143
// Returns the total quantity for a token ID_id uint256 ID of the token to query return amount of token in existence/
function totalSupply( uint256 _id
function totalSupply( uint256 _id
57,187
145
// Adds in liquidity for ETH/usdt
_weth = IERC20(weth).balanceOf(address(this)); uint256 _usdt = IERC20(usdt).balanceOf(address(this)); if (_weth > 0 && _usdt > 0) { IERC20(weth).safeApprove(univ2Router2, 0); IERC20(weth).safeApprove(univ2Router2, _weth); USDT(usdt).approve(univ2Router2, _usdt); UniswapRouterV2(univ2Router2).addLiquidity( weth,
_weth = IERC20(weth).balanceOf(address(this)); uint256 _usdt = IERC20(usdt).balanceOf(address(this)); if (_weth > 0 && _usdt > 0) { IERC20(weth).safeApprove(univ2Router2, 0); IERC20(weth).safeApprove(univ2Router2, _weth); USDT(usdt).approve(univ2Router2, _usdt); UniswapRouterV2(univ2Router2).addLiquidity( weth,
78,424
6
//
* @dev Implementation of the {IERC20} interface. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract BEP20Interface { function totalSupply() public view returns (uint); function balanceOf(address tokenOwner) public view returns (uint balance); function allowance(address tokenOwner, address spender) public view returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); }
* @dev Implementation of the {IERC20} interface. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract BEP20Interface { function totalSupply() public view returns (uint); function balanceOf(address tokenOwner) public view returns (uint balance); function allowance(address tokenOwner, address spender) public view returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); }
2,878
5
// ERC-721 Non-Fungible Token Standard/See https:github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md/Note: the ERC-165 identifier for this interface is 0x80ac58cd.
interface ERC721 /* is ERC165 */ { /// @dev This emits when ownership of any NFT changes by any mechanism. /// This event emits when NFTs are created (`from` == 0) and destroyed /// (`to` == 0). Exception: during contract creation, any number of NFTs /// may be created and assigned without emitting Transfer. At the time of /// any transfer, the approved address for that NFT (if any) is reset to none. event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId); /// @dev This emits when the approved address for an NFT is changed or /// reaffirmed. The zero address indicates there is no approved address. /// When a Transfer event emits, this also indicates that the approved /// address for that NFT (if any) is reset to none. event Approval(address indexed _owner, address indexed _approved, uint256 indexed _tokenId); /// @dev This emits when an operator is enabled or disabled for an owner. /// The operator can manage all NFTs of the owner. event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved); /// @notice Count all NFTs assigned to an owner /// @dev NFTs assigned to the zero address are considered invalid, and this /// function throws for queries about the zero address. /// @param _owner An address for whom to query the balance /// @return The number of NFTs owned by `_owner`, possibly zero function balanceOf(address _owner) external view returns (uint256); /// @notice Find the owner of an NFT /// @dev NFTs assigned to zero address are considered invalid, and queries /// about them do throw. /// @param _tokenId The identifier for an NFT /// @return The address of the owner of the NFT function ownerOf(uint256 _tokenId) external view returns (address); /// @notice Transfers the ownership of an NFT from one address to another address /// @dev Throws unless `msg.sender` is the current owner, an authorized /// operator, or the approved address for this NFT. Throws if `_from` is /// not the current owner. Throws if `_to` is the zero address. Throws if /// `_tokenId` is not a valid NFT. When transfer is complete, this function /// checks if `_to` is a smart contract (code size > 0). If so, it calls /// `onERC721Received` on `_to` and throws if the return value is not /// `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`. /// @param _from The current owner of the NFT /// @param _to The new owner /// @param _tokenId The NFT to transfer /// @param data Additional data with no specified format, sent in call to `_to` function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes data) external; /// @notice Transfers the ownership of an NFT from one address to another address /// @dev This works identically to the other function with an extra data parameter, /// except this function just sets data to "". /// @param _from The current owner of the NFT /// @param _to The new owner /// @param _tokenId The NFT to transfer function safeTransferFrom(address _from, address _to, uint256 _tokenId) external; /// @notice Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE /// TO CONFIRM THAT `_to` IS CAPABLE OF RECEIVING NFTS OR ELSE /// THEY MAY BE PERMANENTLY LOST /// @dev Throws unless `msg.sender` is the current owner, an authorized /// operator, or the approved address for this NFT. Throws if `_from` is /// not the current owner. Throws if `_to` is the zero address. Throws if /// `_tokenId` is not a valid NFT. /// @param _from The current owner of the NFT /// @param _to The new owner /// @param _tokenId The NFT to transfer function transferFrom(address _from, address _to, uint256 _tokenId) external; /// @notice Change or reaffirm the approved address for an NFT /// @dev The zero address indicates there is no approved address. /// Throws unless `msg.sender` is the current NFT owner, or an authorized /// operator of the current owner. /// @param _approved The new approved NFT controller /// @param _tokenId The NFT to approve function approve(address _approved, uint256 _tokenId) external payable; /// @notice Enable or disable approval for a third party ("operator") to manage /// all of `msg.sender`'s assets /// @dev Emits the ApprovalForAll event. The contract MUST allow /// multiple operators per owner. /// @param _operator Address to add to the set of authorized operators /// @param _approved True if the operator is approved, false to revoke approval function setApprovalForAll(address _operator, bool _approved) external; /// @notice Get the approved address for a single NFT /// @dev Throws if `_tokenId` is not a valid NFT. /// @param _tokenId The NFT to find the approved address for /// @return The approved address for this NFT, or the zero address if there is none function getApproved(uint256 _tokenId) external view returns (address); /// @notice Query if an address is an authorized operator for another address /// @param _owner The address that owns the NFTs /// @param _operator The address that acts on behalf of the owner /// @return True if `_operator` is an approved operator for `_owner`, false otherwise function isApprovedForAll(address _owner, address _operator) external view returns (bool); }
interface ERC721 /* is ERC165 */ { /// @dev This emits when ownership of any NFT changes by any mechanism. /// This event emits when NFTs are created (`from` == 0) and destroyed /// (`to` == 0). Exception: during contract creation, any number of NFTs /// may be created and assigned without emitting Transfer. At the time of /// any transfer, the approved address for that NFT (if any) is reset to none. event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId); /// @dev This emits when the approved address for an NFT is changed or /// reaffirmed. The zero address indicates there is no approved address. /// When a Transfer event emits, this also indicates that the approved /// address for that NFT (if any) is reset to none. event Approval(address indexed _owner, address indexed _approved, uint256 indexed _tokenId); /// @dev This emits when an operator is enabled or disabled for an owner. /// The operator can manage all NFTs of the owner. event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved); /// @notice Count all NFTs assigned to an owner /// @dev NFTs assigned to the zero address are considered invalid, and this /// function throws for queries about the zero address. /// @param _owner An address for whom to query the balance /// @return The number of NFTs owned by `_owner`, possibly zero function balanceOf(address _owner) external view returns (uint256); /// @notice Find the owner of an NFT /// @dev NFTs assigned to zero address are considered invalid, and queries /// about them do throw. /// @param _tokenId The identifier for an NFT /// @return The address of the owner of the NFT function ownerOf(uint256 _tokenId) external view returns (address); /// @notice Transfers the ownership of an NFT from one address to another address /// @dev Throws unless `msg.sender` is the current owner, an authorized /// operator, or the approved address for this NFT. Throws if `_from` is /// not the current owner. Throws if `_to` is the zero address. Throws if /// `_tokenId` is not a valid NFT. When transfer is complete, this function /// checks if `_to` is a smart contract (code size > 0). If so, it calls /// `onERC721Received` on `_to` and throws if the return value is not /// `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`. /// @param _from The current owner of the NFT /// @param _to The new owner /// @param _tokenId The NFT to transfer /// @param data Additional data with no specified format, sent in call to `_to` function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes data) external; /// @notice Transfers the ownership of an NFT from one address to another address /// @dev This works identically to the other function with an extra data parameter, /// except this function just sets data to "". /// @param _from The current owner of the NFT /// @param _to The new owner /// @param _tokenId The NFT to transfer function safeTransferFrom(address _from, address _to, uint256 _tokenId) external; /// @notice Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE /// TO CONFIRM THAT `_to` IS CAPABLE OF RECEIVING NFTS OR ELSE /// THEY MAY BE PERMANENTLY LOST /// @dev Throws unless `msg.sender` is the current owner, an authorized /// operator, or the approved address for this NFT. Throws if `_from` is /// not the current owner. Throws if `_to` is the zero address. Throws if /// `_tokenId` is not a valid NFT. /// @param _from The current owner of the NFT /// @param _to The new owner /// @param _tokenId The NFT to transfer function transferFrom(address _from, address _to, uint256 _tokenId) external; /// @notice Change or reaffirm the approved address for an NFT /// @dev The zero address indicates there is no approved address. /// Throws unless `msg.sender` is the current NFT owner, or an authorized /// operator of the current owner. /// @param _approved The new approved NFT controller /// @param _tokenId The NFT to approve function approve(address _approved, uint256 _tokenId) external payable; /// @notice Enable or disable approval for a third party ("operator") to manage /// all of `msg.sender`'s assets /// @dev Emits the ApprovalForAll event. The contract MUST allow /// multiple operators per owner. /// @param _operator Address to add to the set of authorized operators /// @param _approved True if the operator is approved, false to revoke approval function setApprovalForAll(address _operator, bool _approved) external; /// @notice Get the approved address for a single NFT /// @dev Throws if `_tokenId` is not a valid NFT. /// @param _tokenId The NFT to find the approved address for /// @return The approved address for this NFT, or the zero address if there is none function getApproved(uint256 _tokenId) external view returns (address); /// @notice Query if an address is an authorized operator for another address /// @param _owner The address that owns the NFTs /// @param _operator The address that acts on behalf of the owner /// @return True if `_operator` is an approved operator for `_owner`, false otherwise function isApprovedForAll(address _owner, address _operator) external view returns (bool); }
40,282
176
// Subtract the minting fee
total_frax_mint = (frax_amt.mul(PRICE_PRECISION.sub(minting_fee[col_idx]))).div(PRICE_PRECISION);
total_frax_mint = (frax_amt.mul(PRICE_PRECISION.sub(minting_fee[col_idx]))).div(PRICE_PRECISION);
2,928
0
// ------------- EVENTS & VARS -------------
event JuiceBoxMinted(uint256 indexed a); event JuiceBoxBurned(uint256 indexed a);
event JuiceBoxMinted(uint256 indexed a); event JuiceBoxBurned(uint256 indexed a);
10,371
817
// ProposalAccepted event is called when a proposal is accepted so that a server can listen that can /call any offchain actions
event ProposalAccepted (uint256 proposalId);
event ProposalAccepted (uint256 proposalId);
29,132
17
// Use transferFrom() from IERC20.sol
IERC20(erc20Contract).transferFrom(from, NFTOwner, value);
IERC20(erc20Contract).transferFrom(from, NFTOwner, value);
16,278
49
// General payment function for `manager` of LXL contract.details Describes context for ether transfer. /
function tributeToManager(string calldata details) external nonReentrant payable { (bool success, ) = manager.call{value: msg.value}(""); require(success, "!ethCall"); emit TributeToManager(msg.value, details); }
function tributeToManager(string calldata details) external nonReentrant payable { (bool success, ) = manager.call{value: msg.value}(""); require(success, "!ethCall"); emit TributeToManager(msg.value, details); }
8,953
32
// Merkle mint
_checkMerkleAndUpdate(claim, creatorContractAddress, claimIndex, mintIndex, merkleProof, mintFor);
_checkMerkleAndUpdate(claim, creatorContractAddress, claimIndex, mintIndex, merkleProof, mintFor);
2,828
200
// getNativeReputation _avatar the organization avatar.return organization native reputation /
function getNativeReputation(address _avatar) external isAvatarValid(_avatar) view returns(address) { return address(nativeReputation); }
function getNativeReputation(address _avatar) external isAvatarValid(_avatar) view returns(address) { return address(nativeReputation); }
27,277
41
// retrieves the BMI profit of a tokenId/tokenId numeric id identifier of the token/ return profit amount
function getBMIProfit(uint256 tokenId) public view override returns (uint256) { return rewardsGenerator.getReward(_stakersPool[tokenId].policyBookAddress, tokenId); }
function getBMIProfit(uint256 tokenId) public view override returns (uint256) { return rewardsGenerator.getReward(_stakersPool[tokenId].policyBookAddress, tokenId); }
71,127
29
// must be non-zero
if(msg.value <= 0) { revert("donation must be positive"); }
if(msg.value <= 0) { revert("donation must be positive"); }
5,945
8
// public static String asString(){
function asString() public returns(string memory) { string memory ret = ""; uint t=lowestId; while (t< currentId) { string memory a = "["; string memory b = "]"; ret = join(a,join(uint2str(t),join(":",join(toAsciiString(statusMap[t].bidderAddress), join(":",uint2str(statusMap[t].amount)))))); ret = join(ret,b);
function asString() public returns(string memory) { string memory ret = ""; uint t=lowestId; while (t< currentId) { string memory a = "["; string memory b = "]"; ret = join(a,join(uint2str(t),join(":",join(toAsciiString(statusMap[t].bidderAddress), join(":",uint2str(statusMap[t].amount)))))); ret = join(ret,b);
14,847
152
// mint tokens on a wallet Improved version of default mint method. Tokens can be minted to an address if only it is a verified address as per the security token._to Address to mint the tokens to._amount Amount of tokens to mint. This function can only be called by a wallet set as agent of the token emits a `Transfer` event /
function mint(address _to, uint256 _amount) external;
function mint(address _to, uint256 _amount) external;
13,641
92
// Return true if we can run finalizeCrowdsale() properly. This is a safety check function that doesn't allow crowdsale to beginunless the finalizer has been set up properly. /
function isSane() public constant returns (bool);
function isSane() public constant returns (bool);
5,397
151
// Allows the manager to set whether or not only whitelisted addresses can deposit into their fund_onlyWhitelistboolean representing whether only whitelisted addresses can deposit/
function setWhitelistOnly(bool _onlyWhitelist) external onlyOwner { onlyWhitelist = _onlyWhitelist; }
function setWhitelistOnly(bool _onlyWhitelist) external onlyOwner { onlyWhitelist = _onlyWhitelist; }
28,901
32
// clear the stored message
failedMessages[srcChainId][srcAddress][nonce] = bytes32(0);
failedMessages[srcChainId][srcAddress][nonce] = bytes32(0);
21,469
104
// MintableCrowdsaleOnSuccessAgent/Applicature/Contract which takes actions on state change and contribution/ un-pause tokens and disable minting on Crowdsale success/implementation
contract MintableCrowdsaleOnSuccessAgent is CrowdsaleAgent { Crowdsale public crowdsale; MintableToken public token; bool public _isInitialized; constructor(Crowdsale _crowdsale, MintableToken _token) public CrowdsaleAgent(_crowdsale) { crowdsale = _crowdsale; token = _token; if (address(0) != address(_token) && address(0) != address(_crowdsale)) { _isInitialized = true; } else { _isInitialized = false; } } /// @notice Check whether contract is initialised /// @return true if initialized function isInitialized() public constant returns (bool) { return _isInitialized; } /// @notice Takes actions on contribution function onContribution(address _contributor, uint256 _weiAmount, uint256 _tokens, uint256 _bonus) public onlyCrowdsale() { _contributor = _contributor; _weiAmount = _weiAmount; _tokens = _tokens; _bonus = _bonus; // TODO: add impl } /// @notice Takes actions on state change, /// un-pause tokens and disable minting on Crowdsale success /// @param _state Crowdsale.State function onStateChange(Crowdsale.State _state) public onlyCrowdsale() { if (_state == Crowdsale.State.Success) { token.disableMinting(); } } function onRefund(address _contributor, uint256 _tokens) public onlyCrowdsale() returns (uint256 burned) { _contributor = _contributor; _tokens = _tokens; } }
contract MintableCrowdsaleOnSuccessAgent is CrowdsaleAgent { Crowdsale public crowdsale; MintableToken public token; bool public _isInitialized; constructor(Crowdsale _crowdsale, MintableToken _token) public CrowdsaleAgent(_crowdsale) { crowdsale = _crowdsale; token = _token; if (address(0) != address(_token) && address(0) != address(_crowdsale)) { _isInitialized = true; } else { _isInitialized = false; } } /// @notice Check whether contract is initialised /// @return true if initialized function isInitialized() public constant returns (bool) { return _isInitialized; } /// @notice Takes actions on contribution function onContribution(address _contributor, uint256 _weiAmount, uint256 _tokens, uint256 _bonus) public onlyCrowdsale() { _contributor = _contributor; _weiAmount = _weiAmount; _tokens = _tokens; _bonus = _bonus; // TODO: add impl } /// @notice Takes actions on state change, /// un-pause tokens and disable minting on Crowdsale success /// @param _state Crowdsale.State function onStateChange(Crowdsale.State _state) public onlyCrowdsale() { if (_state == Crowdsale.State.Success) { token.disableMinting(); } } function onRefund(address _contributor, uint256 _tokens) public onlyCrowdsale() returns (uint256 burned) { _contributor = _contributor; _tokens = _tokens; } }
18,114
94
// Now give user some STOL
IERC20 stol = IERC20(stolAddress); uint256 maxSupply = StabinolToken(stolAddress).getMaxSupply(); if(stol.totalSupply() < maxSupply){
IERC20 stol = IERC20(stolAddress); uint256 maxSupply = StabinolToken(stolAddress).getMaxSupply(); if(stol.totalSupply() < maxSupply){
5,471
229
// update ALI balance on the contract
aliBalance += aliDelta;
aliBalance += aliDelta;
45,185
6
// Updates the set of claim topics that a trusted issuer is allowed to emit. Requires that this ClaimIssuer contract already exists in the registry Requires that the provided claimTopics set is not empty Requires that there is no more than 15 claimTopics_trustedIssuer the claim issuer to update._claimTopics the set of claim topics that the trusted issuer is allowed to emit This function can only be called by the owner of the Trusted Issuers Registry contract emits a `ClaimTopicsUpdated` event /
function updateIssuerClaimTopics(IClaimIssuer _trustedIssuer, uint256[] calldata _claimTopics) external;
function updateIssuerClaimTopics(IClaimIssuer _trustedIssuer, uint256[] calldata _claimTopics) external;
5,595
14
// limitation of buying tokens
modifier allowCrowdsaleAmountLimit(){ if (msg.value == 0) revert(); if (msg.value < CROWDSALE_ETH_IN_WEI_ACCEPTED_MIN) revert(); if((crowdsale_eth_fund.add(msg.value)) > CROWDSALE_ETH_IN_WEI_FUND_MAX) revert(); if((CROWDSALE_GASPRICE_IN_WEI_MAX > 0) && (tx.gasprice > CROWDSALE_GASPRICE_IN_WEI_MAX)) revert(); _; }
modifier allowCrowdsaleAmountLimit(){ if (msg.value == 0) revert(); if (msg.value < CROWDSALE_ETH_IN_WEI_ACCEPTED_MIN) revert(); if((crowdsale_eth_fund.add(msg.value)) > CROWDSALE_ETH_IN_WEI_FUND_MAX) revert(); if((CROWDSALE_GASPRICE_IN_WEI_MAX > 0) && (tx.gasprice > CROWDSALE_GASPRICE_IN_WEI_MAX)) revert(); _; }
52,246
270
// Get the epoch at the current block timestamp.Reverts if epoch zero has not started. return The current epoch number. /
function getCurrentEpoch() external view returns (uint256)
function getCurrentEpoch() external view returns (uint256)
81,190
4
// ether can be send and received by the contract in the trasaction that calls this function as well
// function sendEther() public payable{ // }
// function sendEther() public payable{ // }
15,726
30
// Sets a new address for the DealManager _newDealManager The address of the new DealManager /
function setDealManager(address _newDealManager) external onlyDealManager { require( _newDealManager != address(0) && _newDealManager != address(this), "DaoDepositManager: Error 100" ); dealManager = IDealManager(_newDealManager); }
function setDealManager(address _newDealManager) external onlyDealManager { require( _newDealManager != address(0) && _newDealManager != address(this), "DaoDepositManager: Error 100" ); dealManager = IDealManager(_newDealManager); }
18,329
166
// Passes a transaction to be executed by the avatar and returns data./Can only be called by this contract./to Destination address of module transaction./value Ether value of module transaction./data Data payload of module transaction./operation Operation type of module transaction: 0 == call, 1 == delegate call.
function execAndReturnData( address to, uint256 value, bytes memory data, Enum.Operation operation
function execAndReturnData( address to, uint256 value, bytes memory data, Enum.Operation operation
16,740
53
// ---------------------------------------------------------------------------- ERC20 Token, with the addition of symbol, name and decimals and a fixed supply ----------------------------------------------------------------------------
contract BTYCToken is ERC20Interface, Owned { using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint _totalSupply; uint256 public sellPrice; //出售价格 1枚代币换多少以太 /1000 uint256 public buyPrice; //购买价格 多少以太可购买1枚代币 /1000 uint256 public sysPrice; //挖矿的衡量值 uint256 public sysPer; //挖矿的增量百分比 /100 uint256 public onceOuttime; //增量的时间 测试 uint256 public onceAddTime; //挖矿的时间 测试 mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; /* 冻结账户 */ mapping(address => bool) public frozenAccount; // 记录各个账户的冻结数目 //mapping(address => uint256) public freezeOf; // 记录各个账户的可用数目 //mapping(address => uint256) public canOf; struct roundsOwn { uint256 addtime; // 添加时间 uint256 addmoney; // 金额 } mapping(address => roundsOwn[]) public mycan; mapping(address => uint256) public tradenum; // 记录各个账户的释放时间 //mapping(address => uint) public cronoutOf; // 记录各个账户的增量时间 mapping(address => uint) public cronaddOf; /* 通知 */ event FrozenFunds(address target, bool frozen); // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "BTYC"; name = "BTYC Coin"; decimals = 18; _totalSupply = 84000000 * 10 ** uint(decimals); sellPrice = 510; //出售价格 1枚代币换多少以太 /1000000 buyPrice = 526; //购买价格 多少以太可购买1枚代币 /1000000 sysPrice = 766; //挖矿的衡量值 sysPer = 225; //挖矿的增量百分比 /100 onceOuttime = 86400; //增量的时间 正式 onceAddTime = 864000; //挖矿的时间 正式 //onceOuttime = 10; //增量的时间 测试 //onceAddTime = 10; //挖矿的时间 测试 balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public view returns(uint balance) { return balances[tokenOwner]; } function addmoney(address _addr, uint256 _money) private{ roundsOwn stateVar; uint256 _now = now; stateVar.addtime = _now; stateVar.addmoney = _money; mycan[_addr].push(stateVar); tradenum[_addr] = tradenum[_addr] + 1; } function getcanuse(address tokenOwner) public view returns(uint balance) { uint256 _now = now; uint256 _left = 0; for(uint256 i = 0; i < tradenum[tokenOwner]; i++) { roundsOwn mydata = mycan[tokenOwner][i]; uint256 stime = mydata.addtime; uint256 smoney = mydata.addmoney; uint256 lefttimes = _now - stime; if(lefttimes >= onceOuttime) { uint256 leftpers = lefttimes / onceOuttime; if(leftpers > 100){ leftpers = 100; } _left = smoney*leftpers/100 + _left; } } return(_left); } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns(bool success) { require(!frozenAccount[msg.sender]); require(!frozenAccount[to]); uint256 canuse = getcanuse(msg.sender); require(canuse >= tokens); //canOf[msg.sender] = myuseOf(msg.sender); //canOf[msg.sender] = canOf[msg.sender].sub(tokens); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); addmoney(to, tokens); emit Transfer(msg.sender, to, tokens); return true; } /* function buytoken(address user, uint256 amount) public{ balances[user] = balances[user].sub(amount); //buyeth(amount); emit Transfer(address(0), user, amount); }*/ // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns(bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns(bool success) { balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public view returns(uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account. The `spender` contract function // `receiveApproval(...)` is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns(bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } /// 冻结 or 解冻账户 function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; emit FrozenFunds(target, freeze); } // 设置销售购买价格 function setPrices(uint256 newBuyPrice, uint256 newSellPrice, uint256 systyPrice, uint256 sysPermit) onlyOwner public { buyPrice = newBuyPrice; sellPrice = newSellPrice; sysPrice = systyPrice; sysPer = sysPermit; } // 获取价格 function getprice() public view returns(uint256 bprice, uint256 spice, uint256 sprice, uint256 sper) { bprice = buyPrice; spice = sellPrice; sprice = sysPrice; sper = sysPer; } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public view returns(uint) { return _totalSupply.sub(balances[address(0)]); } /// 向指定账户拨发资金 function mintToken(address target, uint256 mintedAmount) onlyOwner public { require(!frozenAccount[target]); if(cronaddOf[msg.sender] < 1) { cronaddOf[msg.sender] = now + onceAddTime; } balances[target] += mintedAmount; //_totalSupply -= mintedAmount; addmoney(target, mintedAmount); //emit Transfer(0, this, mintedAmount); emit Transfer(this, target, mintedAmount); } //用户每隔10天挖矿一次 function mintme() public { require(!frozenAccount[msg.sender]); require(now > cronaddOf[msg.sender]); uint256 mintAmount = balances[msg.sender] * sysPer / 10000; balances[msg.sender] += mintAmount; //_totalSupply -= mintAmount; cronaddOf[msg.sender] = now + onceAddTime; addmoney(msg.sender, mintAmount); //emit Transfer(0, this, mintAmount); emit Transfer(this, msg.sender, mintAmount); } function buy(uint256 money) public payable returns(uint256 amount) { require(!frozenAccount[msg.sender]); amount = money * buyPrice; balances[msg.sender] += amount; balances[this] -= amount; //_totalSupply -= amount; addmoney(msg.sender, amount); //msg.sender.transfer(money); emit Transfer(this, msg.sender, amount); return(amount); } function() payable public { buy(msg.value); } /* function selleth(uint amount) public payable { //address user = msg.sender; //canOf[user] = myuseOf(user); //require(balances[user] >= amount ); //uint money = amount * sellPrice; // balances[msg.sender] += money; owner.transfer(amount); }*/ function sell(uint256 amount) public returns(bool success) { //address user = msg.sender; //canOf[msg.sender] = myuseOf(msg.sender); //require(!frozenAccount[msg.sender]); uint256 canuse = getcanuse(msg.sender); require(canuse >= amount); uint moneys = amount / sellPrice; require(msg.sender.send(moneys)); balances[msg.sender] -= amount; balances[this] += amount; //_totalSupply += amount; //canOf[msg.sender] -= amount; //this.transfer(moneys);Transfer(this, msg.sender, revenue); emit Transfer(this, msg.sender, moneys); //canOf[user] -= amount; return(true); } }
contract BTYCToken is ERC20Interface, Owned { using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint _totalSupply; uint256 public sellPrice; //出售价格 1枚代币换多少以太 /1000 uint256 public buyPrice; //购买价格 多少以太可购买1枚代币 /1000 uint256 public sysPrice; //挖矿的衡量值 uint256 public sysPer; //挖矿的增量百分比 /100 uint256 public onceOuttime; //增量的时间 测试 uint256 public onceAddTime; //挖矿的时间 测试 mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; /* 冻结账户 */ mapping(address => bool) public frozenAccount; // 记录各个账户的冻结数目 //mapping(address => uint256) public freezeOf; // 记录各个账户的可用数目 //mapping(address => uint256) public canOf; struct roundsOwn { uint256 addtime; // 添加时间 uint256 addmoney; // 金额 } mapping(address => roundsOwn[]) public mycan; mapping(address => uint256) public tradenum; // 记录各个账户的释放时间 //mapping(address => uint) public cronoutOf; // 记录各个账户的增量时间 mapping(address => uint) public cronaddOf; /* 通知 */ event FrozenFunds(address target, bool frozen); // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "BTYC"; name = "BTYC Coin"; decimals = 18; _totalSupply = 84000000 * 10 ** uint(decimals); sellPrice = 510; //出售价格 1枚代币换多少以太 /1000000 buyPrice = 526; //购买价格 多少以太可购买1枚代币 /1000000 sysPrice = 766; //挖矿的衡量值 sysPer = 225; //挖矿的增量百分比 /100 onceOuttime = 86400; //增量的时间 正式 onceAddTime = 864000; //挖矿的时间 正式 //onceOuttime = 10; //增量的时间 测试 //onceAddTime = 10; //挖矿的时间 测试 balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public view returns(uint balance) { return balances[tokenOwner]; } function addmoney(address _addr, uint256 _money) private{ roundsOwn stateVar; uint256 _now = now; stateVar.addtime = _now; stateVar.addmoney = _money; mycan[_addr].push(stateVar); tradenum[_addr] = tradenum[_addr] + 1; } function getcanuse(address tokenOwner) public view returns(uint balance) { uint256 _now = now; uint256 _left = 0; for(uint256 i = 0; i < tradenum[tokenOwner]; i++) { roundsOwn mydata = mycan[tokenOwner][i]; uint256 stime = mydata.addtime; uint256 smoney = mydata.addmoney; uint256 lefttimes = _now - stime; if(lefttimes >= onceOuttime) { uint256 leftpers = lefttimes / onceOuttime; if(leftpers > 100){ leftpers = 100; } _left = smoney*leftpers/100 + _left; } } return(_left); } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns(bool success) { require(!frozenAccount[msg.sender]); require(!frozenAccount[to]); uint256 canuse = getcanuse(msg.sender); require(canuse >= tokens); //canOf[msg.sender] = myuseOf(msg.sender); //canOf[msg.sender] = canOf[msg.sender].sub(tokens); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); addmoney(to, tokens); emit Transfer(msg.sender, to, tokens); return true; } /* function buytoken(address user, uint256 amount) public{ balances[user] = balances[user].sub(amount); //buyeth(amount); emit Transfer(address(0), user, amount); }*/ // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns(bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns(bool success) { balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public view returns(uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account. The `spender` contract function // `receiveApproval(...)` is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns(bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } /// 冻结 or 解冻账户 function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; emit FrozenFunds(target, freeze); } // 设置销售购买价格 function setPrices(uint256 newBuyPrice, uint256 newSellPrice, uint256 systyPrice, uint256 sysPermit) onlyOwner public { buyPrice = newBuyPrice; sellPrice = newSellPrice; sysPrice = systyPrice; sysPer = sysPermit; } // 获取价格 function getprice() public view returns(uint256 bprice, uint256 spice, uint256 sprice, uint256 sper) { bprice = buyPrice; spice = sellPrice; sprice = sysPrice; sper = sysPer; } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public view returns(uint) { return _totalSupply.sub(balances[address(0)]); } /// 向指定账户拨发资金 function mintToken(address target, uint256 mintedAmount) onlyOwner public { require(!frozenAccount[target]); if(cronaddOf[msg.sender] < 1) { cronaddOf[msg.sender] = now + onceAddTime; } balances[target] += mintedAmount; //_totalSupply -= mintedAmount; addmoney(target, mintedAmount); //emit Transfer(0, this, mintedAmount); emit Transfer(this, target, mintedAmount); } //用户每隔10天挖矿一次 function mintme() public { require(!frozenAccount[msg.sender]); require(now > cronaddOf[msg.sender]); uint256 mintAmount = balances[msg.sender] * sysPer / 10000; balances[msg.sender] += mintAmount; //_totalSupply -= mintAmount; cronaddOf[msg.sender] = now + onceAddTime; addmoney(msg.sender, mintAmount); //emit Transfer(0, this, mintAmount); emit Transfer(this, msg.sender, mintAmount); } function buy(uint256 money) public payable returns(uint256 amount) { require(!frozenAccount[msg.sender]); amount = money * buyPrice; balances[msg.sender] += amount; balances[this] -= amount; //_totalSupply -= amount; addmoney(msg.sender, amount); //msg.sender.transfer(money); emit Transfer(this, msg.sender, amount); return(amount); } function() payable public { buy(msg.value); } /* function selleth(uint amount) public payable { //address user = msg.sender; //canOf[user] = myuseOf(user); //require(balances[user] >= amount ); //uint money = amount * sellPrice; // balances[msg.sender] += money; owner.transfer(amount); }*/ function sell(uint256 amount) public returns(bool success) { //address user = msg.sender; //canOf[msg.sender] = myuseOf(msg.sender); //require(!frozenAccount[msg.sender]); uint256 canuse = getcanuse(msg.sender); require(canuse >= amount); uint moneys = amount / sellPrice; require(msg.sender.send(moneys)); balances[msg.sender] -= amount; balances[this] += amount; //_totalSupply += amount; //canOf[msg.sender] -= amount; //this.transfer(moneys);Transfer(this, msg.sender, revenue); emit Transfer(this, msg.sender, moneys); //canOf[user] -= amount; return(true); } }
46,392
95
// Deposit LP tokens to Mining for token allocation.
function deposit(uint256 _pid, uint256 _amount) public { require(_pid < poolInfo.length, "invalid _pid"); PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; updatePool(_pid); if (user.amount > 0) { uint256 pending = user.amount.mul(pool.accPerShare).div(1e12).sub(user.rewardDebt); user.rewardToClaim = user.rewardToClaim.add(pending); } user.rewardDebt = user.amount.mul(pool.accPerShare).div(1e12); // for gas saving if(_amount > 0) { pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount); if(pool.miningTokenRatioNumerator > 0) { uint256 miningTokenAmount = getMiningTokenAmountByRatio(_amount, pool.miningTokenRatioNumerator); miningToken.safeTransferFrom(msg.sender,address(this), miningTokenAmount); user.miningTokenPledgeAmount = user.miningTokenPledgeAmount.add(miningTokenAmount); } user.amount = user.amount.add(_amount); emit Deposit(msg.sender, _pid, _amount); } }
function deposit(uint256 _pid, uint256 _amount) public { require(_pid < poolInfo.length, "invalid _pid"); PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; updatePool(_pid); if (user.amount > 0) { uint256 pending = user.amount.mul(pool.accPerShare).div(1e12).sub(user.rewardDebt); user.rewardToClaim = user.rewardToClaim.add(pending); } user.rewardDebt = user.amount.mul(pool.accPerShare).div(1e12); // for gas saving if(_amount > 0) { pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount); if(pool.miningTokenRatioNumerator > 0) { uint256 miningTokenAmount = getMiningTokenAmountByRatio(_amount, pool.miningTokenRatioNumerator); miningToken.safeTransferFrom(msg.sender,address(this), miningTokenAmount); user.miningTokenPledgeAmount = user.miningTokenPledgeAmount.add(miningTokenAmount); } user.amount = user.amount.add(_amount); emit Deposit(msg.sender, _pid, _amount); } }
13,953
151
// not state changing but OK because of previous call
uint256 liquidity = want.balanceOf(SOLO); if (liquidity > 1) { uint256 toWithdraw = amount.sub(looseBalance); if (toWithdraw <= liquidity) {
uint256 liquidity = want.balanceOf(SOLO); if (liquidity > 1) { uint256 toWithdraw = amount.sub(looseBalance); if (toWithdraw <= liquidity) {
16,670
7
// /
function whitelistUsers( address[] calldata userAddresses, uint120[] calldata allocations, uint8[] calldata options, bool last
function whitelistUsers( address[] calldata userAddresses, uint120[] calldata allocations, uint8[] calldata options, bool last
13,558
0
// Override such constants while extending BaseAuthorizer.
bool public paused = false;
bool public paused = false;
38,033
24
// Returns value of rewards (CRV, CVX) we can obtain from Convex (nominated in primary tokens)
function getClaimableRewardsValue() external view returns (uint256);
function getClaimableRewardsValue() external view returns (uint256);
31,617
129
// KUSD has 18 decimals KMCD has 18 decimals kMCDPriceMantissa is KMCD's price (quoted by KUSD, has 6 decimals) scaled by 1e36 / KMCD's decimals = 1e36 / 1e18 = 1e18 so the calculation of equivalent KUSD amount is as below accountStakes kMCDPriceMantissa accountStakeskMCDPriceMantissa equivalentKUSDAmount =------------- ------------------1e18 = --------------------------------- 1e181e121e61e30
vars.equivalentKUSDAmount = unstakeKMCDAmount.mul(kMCDPriceMantissa).div(1e18); require(maxBurnKUSDAmount >= vars.equivalentKUSDAmount, "Liquidate: reach out max burn KUSD amount limit");
vars.equivalentKUSDAmount = unstakeKMCDAmount.mul(kMCDPriceMantissa).div(1e18); require(maxBurnKUSDAmount >= vars.equivalentKUSDAmount, "Liquidate: reach out max burn KUSD amount limit");
60,438
36
// Calculates the balance decrements for a set of trades/_values The _values param from the trade method/_decrementsLength Should match the value of _addresses.length / 2/ from the trade method/ return An array of decrements
function calculateTradeDecrements( uint256[] memory _values, uint256 _decrementsLength ) public pure returns (uint256[] memory)
function calculateTradeDecrements( uint256[] memory _values, uint256 _decrementsLength ) public pure returns (uint256[] memory)
18,308
23
// Claim the CANTO for a given market. Can only be performed for prior (i.e. finished) epochs, not the current one/_market Address of the market/_claimFromTimestamp From which epoch (provided as timestmap) should the claim start. Usually, this parameter should be set to 0, in which case the epoch of the last claim will be used./ However, it can be useful to skip certain epochs, e.g. when the balance was very low or 0 (after everything was withdrawn) and the gas usage should be reduced./ Note that all rewards are forfeited forever if epochs are explicitly skipped by providing this parameter/_claimUpToTimestamp Until
function claim( address _market, uint256 _claimFromTimestamp, uint256 _claimUpToTimestamp
function claim( address _market, uint256 _claimFromTimestamp, uint256 _claimUpToTimestamp
9,534
97
// Make sure the cooldown has ends
require(_isCooldownReady(account));
require(_isCooldownReady(account));
69,001
9
// : unpause this gamerequireadmin /
function unpause() public override{ require(msg.sender == admin, "only admin can do unpause operation!"); require(!is_going, "game is already unpaused, please do not repeat this"); is_going = true; }
function unpause() public override{ require(msg.sender == admin, "only admin can do unpause operation!"); require(!is_going, "game is already unpaused, please do not repeat this"); is_going = true; }
3,009
150
// The identifier of the role which is allowed to mint options token
bytes32 public constant MINTER_ROLE = keccak256("MINTER");
bytes32 public constant MINTER_ROLE = keccak256("MINTER");
13,403
140
// Redeem any invested tokens from the pool
function redeem(uint256 _shares) external nonReentrant
function redeem(uint256 _shares) external nonReentrant
6,983
358
// market is not listed, cannot join
if (!marketToJoin.isListed) { return Error.MARKET_NOT_LISTED; }
if (!marketToJoin.isListed) { return Error.MARKET_NOT_LISTED; }
18,506
67
// Call the token and store if it succeeded or not. We use 100 because the calldata length is 4 + 323.
callStatus := call(gas(), token, 0, freeMemoryPointer, 100, 0, 0)
callStatus := call(gas(), token, 0, freeMemoryPointer, 100, 0, 0)
40,068
5
// This function returns who is authorized to set the metadata for your metadata.As an EXAMPLE, we'll only allow the contract deployer to set the contract's metadata.You MUST complete the body of this function to use the `ContractMetadata` extension. /
function _canSetContractURI() internal view virtual override returns (bool){ return msg.sender == owner; }
function _canSetContractURI() internal view virtual override returns (bool){ return msg.sender == owner; }
4,290
6
// Registers with twitter name and full user name (the user name is encrypted). _participant The twitter address of the participant _encrypted The encrypted participant name /
function registerWithEncryption(string _participant, string _encrypted) external payable onlyActive{ registerInternal(_participant); emit RegisterEvent(msg.sender, _participant, _encrypted); }
function registerWithEncryption(string _participant, string _encrypted) external payable onlyActive{ registerInternal(_participant); emit RegisterEvent(msg.sender, _participant, _encrypted); }
52,166
17
// Sets the date of the ICO end.ICO_end The date of the ICO end./
function setEndOfICO(uint ICO_end) public onlyOwner { endOfICO = ICO_end; }
function setEndOfICO(uint ICO_end) public onlyOwner { endOfICO = ICO_end; }
50,681
184
// The block number when Sakura mining starts.
uint256 public startBlock; event Deposit(address indexed user, uint256 indexed pid, uint256 amount); event Withdraw(address indexed user, uint256 indexed pid, uint256 amount); event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount); constructor( SakuraToken _sakura, address _devaddr, uint256 _sakuraPerBlock,
uint256 public startBlock; event Deposit(address indexed user, uint256 indexed pid, uint256 amount); event Withdraw(address indexed user, uint256 indexed pid, uint256 amount); event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount); constructor( SakuraToken _sakura, address _devaddr, uint256 _sakuraPerBlock,
58,247
28
// Updates the address of the price oracle sentinel. newPriceOracleSentinel The address of the new PriceOracleSentinel /
function setPriceOracleSentinel(address newPriceOracleSentinel) external;
function setPriceOracleSentinel(address newPriceOracleSentinel) external;
18,835
51
// Override for MVP (no interests)
return (pay, interests);
return (pay, interests);
27,263
190
// dForce's lending Token admin Contract dForce /
abstract contract TokenAdmin is TokenEvent { //---------------------------------- //********* Owner Actions ********** //---------------------------------- modifier settleInterest() { // Accrues interest. _updateInterest(); require( accrualBlockNumber == block.number, "settleInterest: Fail to accrue interest!" ); _; } /** * @dev Sets a new controller. */ function _setController(IControllerInterface _newController) external virtual onlyOwner { IControllerInterface _oldController = controller; // Ensures the input address is a controller contract. require( _newController.isController(), "_setController: This is not the controller contract!" ); // Sets to new controller. controller = _newController; emit NewController(_oldController, _newController); } /** * @dev Sets a new interest rate model. * @param _newInterestRateModel The new interest rate model. */ function _setInterestRateModel( IInterestRateModelInterface _newInterestRateModel ) external virtual onlyOwner { // Gets current interest rate model. IInterestRateModelInterface _oldInterestRateModel = interestRateModel; // Ensures the input address is the interest model contract. require( _newInterestRateModel.isInterestRateModel(), "_setInterestRateModel: This is not the rate model contract!" ); // Set to the new interest rate model. interestRateModel = _newInterestRateModel; emit NewInterestRateModel(_oldInterestRateModel, _newInterestRateModel); } /** * @dev Sets a new reserve ratio. */ function _setNewReserveRatio(uint256 _newReserveRatio) external virtual onlyOwner settleInterest { require( _newReserveRatio <= maxReserveRatio, "_setNewReserveRatio: New reserve ratio too large!" ); // Gets current reserve ratio. uint256 _oldReserveRatio = reserveRatio; // Sets new reserve ratio. reserveRatio = _newReserveRatio; emit NewReserveRatio(_oldReserveRatio, _newReserveRatio); } /** * @dev Sets a new flashloan fee ratio. */ function _setNewFlashloanFeeRatio(uint256 _newFlashloanFeeRatio) external virtual onlyOwner settleInterest { require( _newFlashloanFeeRatio <= BASE, "setNewFlashloanFeeRatio: New flashloan ratio too large!" ); // Gets current reserve ratio. uint256 _oldFlashloanFeeRatio = flashloanFeeRatio; // Sets new reserve ratio. flashloanFeeRatio = _newFlashloanFeeRatio; emit NewFlashloanFeeRatio(_oldFlashloanFeeRatio, _newFlashloanFeeRatio); } /** * @dev Sets a new protocol fee ratio. */ function _setNewProtocolFeeRatio(uint256 _newProtocolFeeRatio) external virtual onlyOwner settleInterest // nonReentrant { require( _newProtocolFeeRatio <= BASE, "_setNewProtocolFeeRatio: New protocol ratio too large!" ); // Gets current reserve ratio. uint256 _oldProtocolFeeRatio = protocolFeeRatio; // Sets new reserve ratio. protocolFeeRatio = _newProtocolFeeRatio; emit NewProtocolFeeRatio(_oldProtocolFeeRatio, _newProtocolFeeRatio); } /** * @dev Admin withdraws `_withdrawAmount` of the iToken. * @param _withdrawAmount Amount of reserves to withdraw. */ function _withdrawReserves(uint256 _withdrawAmount) external virtual onlyOwner settleInterest // nonReentrant { require( _withdrawAmount <= totalReserves && _withdrawAmount <= _getCurrentCash(), "_withdrawReserves: Invalid withdraw amount and do not have enough cash!" ); uint256 _oldTotalReserves = totalReserves; // Updates total amount of the reserves. totalReserves = totalReserves.sub(_withdrawAmount); // Transfers reserve to the owner. _doTransferOut(owner, _withdrawAmount); emit ReservesWithdrawn( owner, _withdrawAmount, totalReserves, _oldTotalReserves ); } /** * @notice Calculates interest and update total borrows and reserves. * @dev Updates total borrows and reserves with any accumulated interest. */ function _updateInterest() internal virtual; /** * @dev Transfers underlying token out. */ function _doTransferOut(address payable _recipient, uint256 _amount) internal virtual; /** * @dev Total amount of reserves owned by this contract. */ function _getCurrentCash() internal view virtual returns (uint256); }
abstract contract TokenAdmin is TokenEvent { //---------------------------------- //********* Owner Actions ********** //---------------------------------- modifier settleInterest() { // Accrues interest. _updateInterest(); require( accrualBlockNumber == block.number, "settleInterest: Fail to accrue interest!" ); _; } /** * @dev Sets a new controller. */ function _setController(IControllerInterface _newController) external virtual onlyOwner { IControllerInterface _oldController = controller; // Ensures the input address is a controller contract. require( _newController.isController(), "_setController: This is not the controller contract!" ); // Sets to new controller. controller = _newController; emit NewController(_oldController, _newController); } /** * @dev Sets a new interest rate model. * @param _newInterestRateModel The new interest rate model. */ function _setInterestRateModel( IInterestRateModelInterface _newInterestRateModel ) external virtual onlyOwner { // Gets current interest rate model. IInterestRateModelInterface _oldInterestRateModel = interestRateModel; // Ensures the input address is the interest model contract. require( _newInterestRateModel.isInterestRateModel(), "_setInterestRateModel: This is not the rate model contract!" ); // Set to the new interest rate model. interestRateModel = _newInterestRateModel; emit NewInterestRateModel(_oldInterestRateModel, _newInterestRateModel); } /** * @dev Sets a new reserve ratio. */ function _setNewReserveRatio(uint256 _newReserveRatio) external virtual onlyOwner settleInterest { require( _newReserveRatio <= maxReserveRatio, "_setNewReserveRatio: New reserve ratio too large!" ); // Gets current reserve ratio. uint256 _oldReserveRatio = reserveRatio; // Sets new reserve ratio. reserveRatio = _newReserveRatio; emit NewReserveRatio(_oldReserveRatio, _newReserveRatio); } /** * @dev Sets a new flashloan fee ratio. */ function _setNewFlashloanFeeRatio(uint256 _newFlashloanFeeRatio) external virtual onlyOwner settleInterest { require( _newFlashloanFeeRatio <= BASE, "setNewFlashloanFeeRatio: New flashloan ratio too large!" ); // Gets current reserve ratio. uint256 _oldFlashloanFeeRatio = flashloanFeeRatio; // Sets new reserve ratio. flashloanFeeRatio = _newFlashloanFeeRatio; emit NewFlashloanFeeRatio(_oldFlashloanFeeRatio, _newFlashloanFeeRatio); } /** * @dev Sets a new protocol fee ratio. */ function _setNewProtocolFeeRatio(uint256 _newProtocolFeeRatio) external virtual onlyOwner settleInterest // nonReentrant { require( _newProtocolFeeRatio <= BASE, "_setNewProtocolFeeRatio: New protocol ratio too large!" ); // Gets current reserve ratio. uint256 _oldProtocolFeeRatio = protocolFeeRatio; // Sets new reserve ratio. protocolFeeRatio = _newProtocolFeeRatio; emit NewProtocolFeeRatio(_oldProtocolFeeRatio, _newProtocolFeeRatio); } /** * @dev Admin withdraws `_withdrawAmount` of the iToken. * @param _withdrawAmount Amount of reserves to withdraw. */ function _withdrawReserves(uint256 _withdrawAmount) external virtual onlyOwner settleInterest // nonReentrant { require( _withdrawAmount <= totalReserves && _withdrawAmount <= _getCurrentCash(), "_withdrawReserves: Invalid withdraw amount and do not have enough cash!" ); uint256 _oldTotalReserves = totalReserves; // Updates total amount of the reserves. totalReserves = totalReserves.sub(_withdrawAmount); // Transfers reserve to the owner. _doTransferOut(owner, _withdrawAmount); emit ReservesWithdrawn( owner, _withdrawAmount, totalReserves, _oldTotalReserves ); } /** * @notice Calculates interest and update total borrows and reserves. * @dev Updates total borrows and reserves with any accumulated interest. */ function _updateInterest() internal virtual; /** * @dev Transfers underlying token out. */ function _doTransferOut(address payable _recipient, uint256 _amount) internal virtual; /** * @dev Total amount of reserves owned by this contract. */ function _getCurrentCash() internal view virtual returns (uint256); }
71,469
9
// ---------------------------------------- Storage----------------------------------------
ISynthereumFinder public immutable synthereumFinder; mapping(bytes32 => AggregatorV3Interface) private aggregators;
ISynthereumFinder public immutable synthereumFinder; mapping(bytes32 => AggregatorV3Interface) private aggregators;
28,220
4
// ---------------------------------------------------------------------------- Safe math ----------------------------------------------------------------------------
library SafeMath { function add(uint a, uint b) internal pure returns (uint c) { c = a + b; require(c >= a, "Incorrect value"); } function sub(uint a, uint b) internal pure returns (uint c) { require(b <= a, "Incorrect value"); c = a - b; } function mul(uint a, uint b) internal pure returns (uint c) { c = a * b; require(a == 0 || c / a == b, "Incorrect value"); } function div(uint a, uint b) internal pure returns (uint c) { require(b > 0, "Incorrect value"); c = a / b; } }
library SafeMath { function add(uint a, uint b) internal pure returns (uint c) { c = a + b; require(c >= a, "Incorrect value"); } function sub(uint a, uint b) internal pure returns (uint c) { require(b <= a, "Incorrect value"); c = a - b; } function mul(uint a, uint b) internal pure returns (uint c) { c = a * b; require(a == 0 || c / a == b, "Incorrect value"); } function div(uint a, uint b) internal pure returns (uint c) { require(b > 0, "Incorrect value"); c = a / b; } }
40,070
12
// First reset the approved amount if needed
if (allowance > 0) { ERC20(token).safeApprove(spender, 0); }
if (allowance > 0) { ERC20(token).safeApprove(spender, 0); }
29,159
1
// address of token being airdropped.
address public airdropTokenAddress;
address public airdropTokenAddress;
15,030
540
// Check if the deposit has indeed exceeded the time limit of if the exchange is in withdrawal mode
require( block.timestamp >= deposit.timestamp + S.maxAgeDepositUntilWithdrawable || S.isInWithdrawalMode(), "DEPOSIT_NOT_WITHDRAWABLE_YET" ); uint amount = deposit.amount;
require( block.timestamp >= deposit.timestamp + S.maxAgeDepositUntilWithdrawable || S.isInWithdrawalMode(), "DEPOSIT_NOT_WITHDRAWABLE_YET" ); uint amount = deposit.amount;
81,162
424
// Copyright 2019 Dolomite Licensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License atUnless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License. /
pragma solidity 0.5.7;
pragma solidity 0.5.7;
3,119