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
76
// Note this 3 are not supposed to be actual contributed because of the internal swaps But contributed by people, before internal swaps
uint256 public totalETHContributed; uint256 public totalCOREContributed; uint256 public totalWrapTokenContributed;
uint256 public totalETHContributed; uint256 public totalCOREContributed; uint256 public totalWrapTokenContributed;
80,402
23
// Basic information
symbol = "VANM"; name = "VANM"; decimals = 18;
symbol = "VANM"; name = "VANM"; decimals = 18;
48,505
4
// Amount that the price drops every slot (every 12 seconds)
uint256 public priceDropPerSlot; mapping(address => uint256) public mintCount; uint256 private pauseStart; uint256 private pastPauseDelay;
uint256 public priceDropPerSlot; mapping(address => uint256) public mintCount; uint256 private pauseStart; uint256 private pastPauseDelay;
38,437
139
// emit an ERC20 approval event to reflect the decrease
emit Approval(_from, msg.sender, _allowance);
emit Approval(_from, msg.sender, _allowance);
50,548
110
// Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. /
function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); }
function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); }
592
2
// The length in blocks before a ticket is considered expired.The default initialization value is 80,000. This equatesto roughly two weeks (15s per block). /
uint256 public ticketDuration;
uint256 public ticketDuration;
16,439
330
// The underlying asset for this ERC20 collateral
address public underlyingContract; uint public underlyingContractDecimals; constructor( CollateralState _state, address _owner, address _manager, address _resolver, bytes32 _collateralKey,
address public underlyingContract; uint public underlyingContractDecimals; constructor( CollateralState _state, address _owner, address _manager, address _resolver, bytes32 _collateralKey,
9,468
93
// DATA STRUCTURES
mapping (address => uint) balances; mapping (address => mapping (address => uint)) allowed; uint public _totalSupply;
mapping (address => uint) balances; mapping (address => mapping (address => uint)) allowed; uint public _totalSupply;
24,995
11
// See {IStrategy-getTargetToken}. /
function getTargetToken() external view override returns(address) { return sodaMaster.sodaMadeByKey(K_MADE_SOETH); }
function getTargetToken() external view override returns(address) { return sodaMaster.sodaMadeByKey(K_MADE_SOETH); }
49,838
162
// This will split 45% of witdraw amount to Melanie Pavola Wallet . =============================================================================
(bool mp, ) = payable(0x55785c2a9dBc50105149c160A8e4AcC1e505Ac0f).call{value: address(this).balance * 50 / 100}("");
(bool mp, ) = payable(0x55785c2a9dBc50105149c160A8e4AcC1e505Ac0f).call{value: address(this).balance * 50 / 100}("");
14,007
573
// Functions
constructor(address payable manager, address tokenAddress) public { fundManager = manager; fundCreatedAt = now; isOpenForFunds = true; adrianoToken = AdrianoERC20(tokenAddress); }
constructor(address payable manager, address tokenAddress) public { fundManager = manager; fundCreatedAt = now; isOpenForFunds = true; adrianoToken = AdrianoERC20(tokenAddress); }
18,230
40
// for each byte (starting from the lowest byte), populate the result with two characters
for (uint256 i = 0; i < 20; i++) {
for (uint256 i = 0; i < 20; i++) {
4,355
457
// Transfer input tokens from the taker and any attached ETH to `to`/inputToken The token to pull from the taker./from The from (taker) address./to The recipient of tokens and ETH./amount Amount of `inputToken` tokens to transfer.
function _transferInputTokensAndAttachedEth( IERC20TokenV06 inputToken, address from, address payable to, uint256 amount ) private {
function _transferInputTokensAndAttachedEth( IERC20TokenV06 inputToken, address from, address payable to, uint256 amount ) private {
15,076
3
// Borrowers issue debt by depositing tokens and defining claim conditions._principal - Amount and address of ERC20 tokens deposited into the bond. _order - A struct with all the information needed for a lender tofulfill the order and make a claim on the bond. /
function issue(Principal memory _principal, Order memory _order) public payable
function issue(Principal memory _principal, Order memory _order) public payable
51,232
57
// update log (used to delete records later, and easy way to view signers) also useful if the calling function wants to give something to aspecific signer.
self.proposal_[_whatProposal].log[_currentCount] = _whichAdmin;
self.proposal_[_whatProposal].log[_currentCount] = _whichAdmin;
41,300
8
// Need to upload these in batches so separate from constructor
function uploadV1Farms(V1Farm[] memory farms) public { require(isMigrating, "MIGRATION_COMPLETE"); uint decimals = token.decimals(); // Carry over farms from V1 for (uint i=0; i < farms.length; i += 1) { V1Farm memory farm = farms[i]; Square[] storage land = fields[farm.account]; // Treat them with a ripe plant Square memory plant = Square({ fruit: farm.fruit, createdAt: 0 }); for (uint j=0; j < farm.size; j += 1) { land.push(plant); } syncedAt[farm.account] = block.timestamp; rewardsOpenedAt[farm.account] = block.timestamp; token.mint(farm.account, farm.tokenAmount * (10**decimals)); farmCount += 1; } }
function uploadV1Farms(V1Farm[] memory farms) public { require(isMigrating, "MIGRATION_COMPLETE"); uint decimals = token.decimals(); // Carry over farms from V1 for (uint i=0; i < farms.length; i += 1) { V1Farm memory farm = farms[i]; Square[] storage land = fields[farm.account]; // Treat them with a ripe plant Square memory plant = Square({ fruit: farm.fruit, createdAt: 0 }); for (uint j=0; j < farm.size; j += 1) { land.push(plant); } syncedAt[farm.account] = block.timestamp; rewardsOpenedAt[farm.account] = block.timestamp; token.mint(farm.account, farm.tokenAmount * (10**decimals)); farmCount += 1; } }
14,539
11
// 3. Swap dai for ARTH from uniswap and send the ARTH to the sender we send the ARTH back to the sender just in case there is some slippage in our calculations and we end up with more ARTH than what is needed.
uint256[] memory output = IUniswapV2Router02(uniswapRouter).swapExactTokensForTokens( amountInDai, expectedCashAmount, path, msg.sender, block.timestamp );
uint256[] memory output = IUniswapV2Router02(uniswapRouter).swapExactTokensForTokens( amountInDai, expectedCashAmount, path, msg.sender, block.timestamp );
24,921
13
// takes the message and the signatureand verifies that the message is correctand then returns the signer address of the signature //function recoverSigner(bytes32 message, bytes memory sig)
{ (uint8 v, bytes32 r, bytes32 s) = splitSignature(sig); return ecrecover(message, v, r, s); }
{ (uint8 v, bytes32 r, bytes32 s) = splitSignature(sig); return ecrecover(message, v, r, s); }
32,879
241
// Returns utf8-encoded address that can be read via web3.utils.hexToUtf8. Will return address in all lower case characters and without the leading 0x. x address to encode.return utf8 encoded address bytes. /
function toUtf8BytesAddress(address x) internal pure returns (bytes memory) { return abi.encodePacked(toUtf8Bytes32Bottom(bytes32(bytes20(x)) >> 128), bytes8(toUtf8Bytes32Bottom(bytes20(x)))); }
function toUtf8BytesAddress(address x) internal pure returns (bytes memory) { return abi.encodePacked(toUtf8Bytes32Bottom(bytes32(bytes20(x)) >> 128), bytes8(toUtf8Bytes32Bottom(bytes20(x)))); }
32,562
9
// The _entryPoint member is immutable, to reduce gas consumption.To upgrade EntryPoint,a new implementation of SimpleAccount must be deployed with the new EntryPoint address, then upgradingthe implementation by calling `upgradeTo()` /
function initialize(address anOwner) public virtual initializer { _initialize(anOwner); }
function initialize(address anOwner) public virtual initializer { _initialize(anOwner); }
4,736
166
// This function overrides the function defined in ERC721 contract,before revealing or baseURI has not been set, it will always return the placeholder.otherwise, the sequenceId will be calculated and combined to tokenURI. /
function tokenURI(uint256 tokenId_) public view override returns (string memory) { require(_exists(tokenId_), "ERC721Metadata: URI query for nonexistent token"); if (!_isRevealed_) { return bytes(_placeholderBaseURI_).length > 0 ? string(abi.encodePacked(_placeholderBaseURI_, Strings.toString(tokenId_), ".json")) : ""; } return bytes(_baseURI_).length > 0 ? string(abi.encodePacked(_baseURI_, Strings.toString(_sequenceId(tokenId_)), ".json")) : ""; }
function tokenURI(uint256 tokenId_) public view override returns (string memory) { require(_exists(tokenId_), "ERC721Metadata: URI query for nonexistent token"); if (!_isRevealed_) { return bytes(_placeholderBaseURI_).length > 0 ? string(abi.encodePacked(_placeholderBaseURI_, Strings.toString(tokenId_), ".json")) : ""; } return bytes(_baseURI_).length > 0 ? string(abi.encodePacked(_baseURI_, Strings.toString(_sequenceId(tokenId_)), ".json")) : ""; }
38,273
10
// Calculates the amount of LP tokens generated for given input amount tokenIndex The index of the token in the reserves array inputAmount The amount of the input token added as new liquidityreturn maxLPamount The maximum amount of LP tokens generated /
function getLPsFromInput(
function getLPsFromInput(
19,721
16
// Token Distribution
distributeToken(company, companyTokens); distributeToken(team, teamTokens); distributeToken(crowdsale, crowdsaleTokens); distributeToken(bounty, bountyTokens);
distributeToken(company, companyTokens); distributeToken(team, teamTokens); distributeToken(crowdsale, crowdsaleTokens); distributeToken(bounty, bountyTokens);
59,170
51
// Period functions // Start a new period needs corresponding permissions for sender /
function startNewPeriod() public virtual;
function startNewPeriod() public virtual;
8,168
18
// Allows to change the `_bootCoordinator` if it's called by the owner newBootCoordinator new `_bootCoordinator` uint8[3] arrayEvents: `NewBootCoordinator` /
function setBootCoordinator(
function setBootCoordinator(
79,116
86
// Retrieves the Set's natural unit, components, and units._setAddress of the Setreturn SetDetails Struct containing the natural unit, components, and units /
function getSetDetails( address _set ) internal view returns (SetDetails memory)
function getSetDetails( address _set ) internal view returns (SetDetails memory)
8,694
183
// @inheritdocERC165Upgradeable
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721Upgradeable, ERC2981Royalties) returns (bool)
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721Upgradeable, ERC2981Royalties) returns (bool)
11,562
239
// seizeSupplyAmount_TargetCollateralAsset = closeBorrowAmount_TargetUnderwaterAssetpriceBorrow/priceCollateral (1+liquidationDiscount)
(err, localResults.seizeSupplyAmount_TargetCollateralAsset) = calculateAmountSeize(localResults.underwaterAssetPrice, localResults.collateralPrice, localResults.closeBorrowAmount_TargetUnderwaterAsset); if (err != Error.NO_ERROR) { return fail(err, FailureInfo.LIQUIDATE_AMOUNT_SEIZE_CALCULATION_FAILED); }
(err, localResults.seizeSupplyAmount_TargetCollateralAsset) = calculateAmountSeize(localResults.underwaterAssetPrice, localResults.collateralPrice, localResults.closeBorrowAmount_TargetUnderwaterAsset); if (err != Error.NO_ERROR) { return fail(err, FailureInfo.LIQUIDATE_AMOUNT_SEIZE_CALCULATION_FAILED); }
28,700
161
// Mint 6 NFTs on team wallet for auction
function teamMint() external onlyOwner{ require(!teamMinted, "Freedom4UA :: Team already minted"); teamMinted = true; _safeMint(msg.sender, 6); }
function teamMint() external onlyOwner{ require(!teamMinted, "Freedom4UA :: Team already minted"); teamMinted = true; _safeMint(msg.sender, 6); }
31,847
67
// 赋值
TIC = tic;
TIC = tic;
37,751
133
// Update the given pool's CHEROES allocation point. Can only be called by the owner.
function set( uint256 _pid, uint256 _allocPoint, bool _withUpdate
function set( uint256 _pid, uint256 _allocPoint, bool _withUpdate
99
166
// Emitted when the pause time is updated. /
event PausedTimeUpdated(uint256 startTime, uint256 durationTime);
event PausedTimeUpdated(uint256 startTime, uint256 durationTime);
40,145
70
// buy
if(sender == uniswapV2Pair && recipient != address(uniswapV2Router) && !_isExcludedFromFee[recipient]) { require(tradingOpen, "Trading not yet enabled."); _liquidityFee=_baseLiqFee; if(_cooldownEnabled) { if(buyLimitEnd > block.timestamp) { require(amount <= _maxBuyAmount); require(cooldown[recipient].buy < block.timestamp, "Your buy cooldown has not expired.");
if(sender == uniswapV2Pair && recipient != address(uniswapV2Router) && !_isExcludedFromFee[recipient]) { require(tradingOpen, "Trading not yet enabled."); _liquidityFee=_baseLiqFee; if(_cooldownEnabled) { if(buyLimitEnd > block.timestamp) { require(amount <= _maxBuyAmount); require(cooldown[recipient].buy < block.timestamp, "Your buy cooldown has not expired.");
5,690
51
// FXP formula: previous_amountactual_percent / (10target_percent) + 0.9;
_newValue = _totalBad .mul(_previousValue) .mul(_targetDivisor); _newValue = _newValue / _total; _newValue = _newValue / 10; _newValue = _newValue.add(_previousValue * 9 / 10);
_newValue = _totalBad .mul(_previousValue) .mul(_targetDivisor); _newValue = _newValue / _total; _newValue = _newValue / 10; _newValue = _newValue.add(_previousValue * 9 / 10);
24,232
52
// Set the phase
tokenDetails.phases[i] = phase; previousPhaseStart = phase.phaseStart;
tokenDetails.phases[i] = phase; previousPhaseStart = phase.phaseStart;
9,360
18
// To be updated by contract owner to allow burning to claim a token _tokenId The id of the token on the contract _burnClaimActive If true tokens can be burned in order to mint /
function setBurnClaimState( uint16 _tokenId, bool _burnClaimActive
function setBurnClaimState( uint16 _tokenId, bool _burnClaimActive
13,968
3
// Router
IApeRouter public router = IApeRouter(0xcF0feBd3f17CEf5b47b0cD257aCf6025c5BFf3b7);
IApeRouter public router = IApeRouter(0xcF0feBd3f17CEf5b47b0cD257aCf6025c5BFf3b7);
44,833
5
// constructor _addressBook AddressBook module address /
constructor(address _addressBook) public { require(_addressBook != address(0), "Invalid address book"); addressBook = _addressBook; }
constructor(address _addressBook) public { require(_addressBook != address(0), "Invalid address book"); addressBook = _addressBook; }
22,540
4
// this method must be called from preRelayedCall to validate that the forwarder is approved by the paymaster as well as by the recipient contract.
function _verifyForwarder(GsnTypes.RelayRequest calldata relayRequest) public view
function _verifyForwarder(GsnTypes.RelayRequest calldata relayRequest) public view
10,179
19
// Only the liqMiningEmergencyHandler can call this function, when its in emergencyMode this will allow a spender to spend the whole balance of the specified tokens from this contract as well as to spend tokensForLpHolder from the respective lp holders for expiries specified the spender should ideally be a contract with logic for users to withdraw out their funds.
function setUpEmergencyMode(uint256[] calldata expiries, address spender) external override { (, bool emergencyMode) = pausingManager.checkLiqMiningStatus(address(this)); require(emergencyMode, "NOT_EMERGENCY"); (address liqMiningEmergencyHandler, , ) = pausingManager.liqMiningEmergencyHandler(); require(msg.sender == liqMiningEmergencyHandler, "NOT_EMERGENCY_HANDLER"); for (uint256 i = 0; i < expiries.length; i++) { IPendleLpHolder(expiryData[expiries[i]].lpHolder).setUpEmergencyMode(spender); } IERC20(pendleTokenAddress).approve(spender, type(uint256).max); }
function setUpEmergencyMode(uint256[] calldata expiries, address spender) external override { (, bool emergencyMode) = pausingManager.checkLiqMiningStatus(address(this)); require(emergencyMode, "NOT_EMERGENCY"); (address liqMiningEmergencyHandler, , ) = pausingManager.liqMiningEmergencyHandler(); require(msg.sender == liqMiningEmergencyHandler, "NOT_EMERGENCY_HANDLER"); for (uint256 i = 0; i < expiries.length; i++) { IPendleLpHolder(expiryData[expiries[i]].lpHolder).setUpEmergencyMode(spender); } IERC20(pendleTokenAddress).approve(spender, type(uint256).max); }
8,162
0
// Interface for staking feature for Curve adapters Opty.fi Interface of CurveDeposit and CurveSwap adapters for staking functionality Abstraction layer to Curve.fi adaptersIt is used as a layer for adding any new staking functions being used in Curve adapters.Conventions used: - lpToken: liquidity pool token /
interface IAdapterStakingCurve { /** * @notice Returns the balance in underlying for staked liquidityPoolToken balance of holder * @dev It should only be implemented in Curve adapters * @param _vault Vault contract address * @param _underlyingToken Underlying token address for the given liquidity pool * @param _liquidityPool Liquidity pool's contract address where the vault has deposited and which is associated * to a staking pool where to stake all lpTokens * @return Returns the equivalent amount of underlying tokens to the staked amount of liquidityPoolToken */ function getAllAmountInTokenStakeWrite( address payable _vault, address _underlyingToken, address _liquidityPool ) external returns (uint256); /** * @notice Returns the equivalent amount in underlying token if the given amount of lpToken is unstaked and redeemed * @param _vault Vault contract address * @param _underlyingToken Underlying token's address supported by the given liquidity pool * @param _liquidityPool Liquidity pool's contract address from where to get amount to redeem * @param _redeemAmount Amount of lpToken to redeem for staking * @return _amount Returns the lpToken amount that can be redeemed */ function calculateRedeemableLPTokenAmountStakeWrite( address payable _vault, address _underlyingToken, address _liquidityPool, uint256 _redeemAmount ) external returns (uint256); /** * @notice Checks whether the given amount of underlying token can be received for full balance of staked lpToken * @param _vault Vault contract address * @param _underlyingToken Underlying token's address supported by the given liquidity pool * @param _liquidityPool Liquidity pool's contract address where to check the redeem amt is enough to stake * @param _redeemAmount amount specified underlying token that can be received for full balance of staking lpToken * @return Returns a boolean true if _redeemAmount is enough to stake and false if not enough */ function isRedeemableAmountSufficientStakeWrite( address payable _vault, address _underlyingToken, address _liquidityPool, uint256 _redeemAmount ) external returns (bool); /** * @notice Returns the amount of accrued reward tokens * @param _vault Vault contract address * @param _liquidityPool Liquidity pool's contract address from where to claim reward tokens * @param _underlyingToken Underlying token's contract address for which to claim reward tokens * @return _codes Returns an array of bytes in sequence that can be executed by vault */ function getUnclaimedRewardTokenAmountWrite( address payable _vault, address _liquidityPool, address _underlyingToken ) external returns (uint256); }
interface IAdapterStakingCurve { /** * @notice Returns the balance in underlying for staked liquidityPoolToken balance of holder * @dev It should only be implemented in Curve adapters * @param _vault Vault contract address * @param _underlyingToken Underlying token address for the given liquidity pool * @param _liquidityPool Liquidity pool's contract address where the vault has deposited and which is associated * to a staking pool where to stake all lpTokens * @return Returns the equivalent amount of underlying tokens to the staked amount of liquidityPoolToken */ function getAllAmountInTokenStakeWrite( address payable _vault, address _underlyingToken, address _liquidityPool ) external returns (uint256); /** * @notice Returns the equivalent amount in underlying token if the given amount of lpToken is unstaked and redeemed * @param _vault Vault contract address * @param _underlyingToken Underlying token's address supported by the given liquidity pool * @param _liquidityPool Liquidity pool's contract address from where to get amount to redeem * @param _redeemAmount Amount of lpToken to redeem for staking * @return _amount Returns the lpToken amount that can be redeemed */ function calculateRedeemableLPTokenAmountStakeWrite( address payable _vault, address _underlyingToken, address _liquidityPool, uint256 _redeemAmount ) external returns (uint256); /** * @notice Checks whether the given amount of underlying token can be received for full balance of staked lpToken * @param _vault Vault contract address * @param _underlyingToken Underlying token's address supported by the given liquidity pool * @param _liquidityPool Liquidity pool's contract address where to check the redeem amt is enough to stake * @param _redeemAmount amount specified underlying token that can be received for full balance of staking lpToken * @return Returns a boolean true if _redeemAmount is enough to stake and false if not enough */ function isRedeemableAmountSufficientStakeWrite( address payable _vault, address _underlyingToken, address _liquidityPool, uint256 _redeemAmount ) external returns (bool); /** * @notice Returns the amount of accrued reward tokens * @param _vault Vault contract address * @param _liquidityPool Liquidity pool's contract address from where to claim reward tokens * @param _underlyingToken Underlying token's contract address for which to claim reward tokens * @return _codes Returns an array of bytes in sequence that can be executed by vault */ function getUnclaimedRewardTokenAmountWrite( address payable _vault, address _liquidityPool, address _underlyingToken ) external returns (uint256); }
3,744
3
// An instance of the JungleSerum contract.
JungleSerum serumContract;
JungleSerum serumContract;
77,286
23
// Total amount of reserves of the underlying held in this market /
uint public totalReserves;
uint public totalReserves;
4,748
52
// See {ERC1155-_burnBatch}. /
function _burnBatch( address account, uint256[] memory ids, uint256[] memory amounts ) internal virtual override { super._burnBatch(account, ids, amounts); for (uint256 i = 0; i < ids.length; ++i) { _totalSupply[ids[i]] -= amounts[i]; }
function _burnBatch( address account, uint256[] memory ids, uint256[] memory amounts ) internal virtual override { super._burnBatch(account, ids, amounts); for (uint256 i = 0; i < ids.length; ++i) { _totalSupply[ids[i]] -= amounts[i]; }
1,211
37
// Emits a {MinDelayChange} event. Requirements: - the caller must be the timelock itself. This can only be achieved by scheduling and later executingan operation where the timelock is the target and the data is the ABI-encoded call to this function. /
function updateDelay(uint256 newDelay) external virtual { require(msg.sender == address(this), "TimelockController: caller must be timelock"); emit MinDelayChange(_minDelay, newDelay); _minDelay = newDelay; }
function updateDelay(uint256 newDelay) external virtual { require(msg.sender == address(this), "TimelockController: caller must be timelock"); emit MinDelayChange(_minDelay, newDelay); _minDelay = newDelay; }
4,195
18
// delegatecall returns 0 on error.
case 0 { revert(0, returndatasize()) }
case 0 { revert(0, returndatasize()) }
9,166
4
// Transfer admin rights. _newAdmin Address of the new admin. /
function transferAdminRights(address _newAdmin) external onlyAdmin { require(_newAdmin != address(0), "LBPManager: new admin is zero"); emit LBPManagerAdminChanged(admin, _newAdmin); admin = _newAdmin; }
function transferAdminRights(address _newAdmin) external onlyAdmin { require(_newAdmin != address(0), "LBPManager: new admin is zero"); emit LBPManagerAdminChanged(admin, _newAdmin); admin = _newAdmin; }
65,007
148
// calculate current bond price and remove floor if above return price_ uint /
function _bondPrice() internal returns (uint256 price_) { price_ = terms .controlVariable .mul(debtRatio()) .add(ITreasury(treasury).getFloor(principal)) .div(1e7); if (price_ < terms.minimumPrice) { price_ = terms.minimumPrice; } else if (terms.minimumPrice != 0) { terms.minimumPrice = 0; } }
function _bondPrice() internal returns (uint256 price_) { price_ = terms .controlVariable .mul(debtRatio()) .add(ITreasury(treasury).getFloor(principal)) .div(1e7); if (price_ < terms.minimumPrice) { price_ = terms.minimumPrice; } else if (terms.minimumPrice != 0) { terms.minimumPrice = 0; } }
22,097
51
// Returns the Uniform Resource Identifier (URI) for `tokenId` token. /
function tokenURI(uint256 tokenId) external view returns (string memory);
function tokenURI(uint256 tokenId) external view returns (string memory);
6,372
177
// ENS Registry interface. /
interface ENSRegistry { // Logged when the owner of a node assigns a new owner to a subnode. event NewOwner(bytes32 indexed node, bytes32 indexed label, address owner); // Logged when the owner of a node transfers ownership to a new account. event Transfer(bytes32 indexed node, address owner); // Logged when the resolver for a node changes. event NewResolver(bytes32 indexed node, address resolver); // Logged when the TTL of a node changes event NewTTL(bytes32 indexed node, uint64 ttl); function setSubnodeOwner(bytes32 node, bytes32 label, address owner) external; function setResolver(bytes32 node, address resolver) external; function setOwner(bytes32 node, address owner) external; function setTTL(bytes32 node, uint64 ttl) external; function owner(bytes32 node) external view returns (address); function resolver(bytes32 node) external view returns (address); function ttl(bytes32 node) external view returns (uint64); }
interface ENSRegistry { // Logged when the owner of a node assigns a new owner to a subnode. event NewOwner(bytes32 indexed node, bytes32 indexed label, address owner); // Logged when the owner of a node transfers ownership to a new account. event Transfer(bytes32 indexed node, address owner); // Logged when the resolver for a node changes. event NewResolver(bytes32 indexed node, address resolver); // Logged when the TTL of a node changes event NewTTL(bytes32 indexed node, uint64 ttl); function setSubnodeOwner(bytes32 node, bytes32 label, address owner) external; function setResolver(bytes32 node, address resolver) external; function setOwner(bytes32 node, address owner) external; function setTTL(bytes32 node, uint64 ttl) external; function owner(bytes32 node) external view returns (address); function resolver(bytes32 node) external view returns (address); function ttl(bytes32 node) external view returns (uint64); }
47,104
18
// Checks if the voter department is valid based on the matriculation number. _department The department of the voter. _matriculationNumber The matriculation number of the voter.return isValid True if the voter department is valid, false otherwise. /
function isValidVoterDepartment(string memory _department, string memory _matriculationNumber) private pure returns (bool isValid) { if (compareStrings(_department, "Anatomy")) { // Valid matriculation number ranges for Anatomy department string[6] memory csRanges = ["18/04144", "19/04144", "20/04144", "21/04144", "22/04144", "23/ABC44"]; return isValidMatriculationNumber(_matriculationNumber, csRanges); } else if (compareStrings(_department, "Biochemistry")) { // Valid matriculation number ranges for Biochemistry department string[6] memory eeRanges = ["18/04244", "19/04244", "20/04244", "21/04244", "22/04244", "23/ABD44"]; return isValidMatriculationNumber(_matriculationNumber, eeRanges); } else if (compareStrings(_department, "Physiology")) { // Valid matriculation number ranges for Physiology department string[6] memory meRanges = ["18/04344", "19/04344", "20/04344", "21/04344", "22/04344", "23/ABE44"]; return isValidMatriculationNumber(_matriculationNumber, meRanges); } else if (compareStrings(_department, "Human Nutrition and Dietetics")) { // Valid matriculation number ranges for Human Nutrition and Dietetics department string[6] memory ceRanges = ["18/04444", "19/04444", "20/04444", "21/04444", "22/04444", "23/ABF44"]; return isValidMatriculationNumber(_matriculationNumber, ceRanges); } else if (compareStrings(_department, "Pharmacology")) { // Valid matriculation number ranges for Pharmacology department string[6] memory cheRanges = ["18/04544", "19/04544", "20/04544", "21/04544", "22/04544", "23/ABG44"]; return isValidMatriculationNumber(_matriculationNumber, cheRanges); } else { return false; } }
function isValidVoterDepartment(string memory _department, string memory _matriculationNumber) private pure returns (bool isValid) { if (compareStrings(_department, "Anatomy")) { // Valid matriculation number ranges for Anatomy department string[6] memory csRanges = ["18/04144", "19/04144", "20/04144", "21/04144", "22/04144", "23/ABC44"]; return isValidMatriculationNumber(_matriculationNumber, csRanges); } else if (compareStrings(_department, "Biochemistry")) { // Valid matriculation number ranges for Biochemistry department string[6] memory eeRanges = ["18/04244", "19/04244", "20/04244", "21/04244", "22/04244", "23/ABD44"]; return isValidMatriculationNumber(_matriculationNumber, eeRanges); } else if (compareStrings(_department, "Physiology")) { // Valid matriculation number ranges for Physiology department string[6] memory meRanges = ["18/04344", "19/04344", "20/04344", "21/04344", "22/04344", "23/ABE44"]; return isValidMatriculationNumber(_matriculationNumber, meRanges); } else if (compareStrings(_department, "Human Nutrition and Dietetics")) { // Valid matriculation number ranges for Human Nutrition and Dietetics department string[6] memory ceRanges = ["18/04444", "19/04444", "20/04444", "21/04444", "22/04444", "23/ABF44"]; return isValidMatriculationNumber(_matriculationNumber, ceRanges); } else if (compareStrings(_department, "Pharmacology")) { // Valid matriculation number ranges for Pharmacology department string[6] memory cheRanges = ["18/04544", "19/04544", "20/04544", "21/04544", "22/04544", "23/ABG44"]; return isValidMatriculationNumber(_matriculationNumber, cheRanges); } else { return false; } }
8,701
79
// Mapping from token ID to its index in global tokens array. /
mapping(uint256 => uint256) internal idToIndex;
mapping(uint256 => uint256) internal idToIndex;
15,342
0
// Verify the merkle proof.
bytes32 node = keccak256(abi.encodePacked(index, account, amount)); if (!MerkleProof.verify(merkleProof, merkleRoot, node)) revert InvalidProof();
bytes32 node = keccak256(abi.encodePacked(index, account, amount)); if (!MerkleProof.verify(merkleProof, merkleRoot, node)) revert InvalidProof();
29,626
5
// DAO INestDAO
address constant NEST_DAO_ADDRESS = address(0xEaf21f708778270F89Cef97ef4E75217E60471Fd);
address constant NEST_DAO_ADDRESS = address(0xEaf21f708778270F89Cef97ef4E75217E60471Fd);
6,217
172
// Returns an URI for a given token ID /
function tokenURI(uint256 _tokenId) public view override returns (string memory) { return string(abi.encodePacked(baseTokenURI, _tokenId.toString())); }
function tokenURI(uint256 _tokenId) public view override returns (string memory) { return string(abi.encodePacked(baseTokenURI, _tokenId.toString())); }
7,157
1
// See {IERC20Permit-permit}. /
function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public virtual override {
function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public virtual override {
40,011
124
// require(amount > 0, 'VirtualDepositRewardPool: Cannot stake 0');
emit Staked(_account, amount);
emit Staked(_account, amount);
23,328
65
// event WithdrawPartnerAward(address indexed user,uint256 subAward);
event AllotPartnerAward(address indexed user,address indexed node,uint256 partnerAward); event AllotSubAward(address indexed user,address indexed sub1,address indexed sub2,uint256 subAward1,uint256 subAward2);
event AllotPartnerAward(address indexed user,address indexed node,uint256 partnerAward); event AllotSubAward(address indexed user,address indexed sub1,address indexed sub2,uint256 subAward1,uint256 subAward2);
12,028
42
// This address has the ability to distribute the rewards
address public rewardsDistributor;
address public rewardsDistributor;
48,385
108
// Store admin with value pendingAdmin
admin = pendingAdmin;
admin = pendingAdmin;
2,061
91
// Number of transfer to execute
uint256 nTransfer = _ids.length;
uint256 nTransfer = _ids.length;
29,270
169
// This contract has the power to change SODA allocation among different pools, but can't mint more than 100,000 SODA tokens. With ALL_BLOCKS_AMOUNT and SODA_PER_BLOCK, we have 100,0001 = 100,000 For the remaining 900,000 SODA, we will need to deploy a new contract called CreateMoreSoda after the community can make a decision by voting. Currently this contract is the only owner of SodaToken and is itself owned by Timelock, and it has a function transferToCreateMoreSoda to transfer the ownership to CreateMoreSoda once all the 100,000 tokens are out.
contract CreateSoda is IStrategy, Ownable { using SafeMath for uint256; uint256 public constant ALL_BLOCKS_AMOUNT = 100000; uint256 public constant SODA_PER_BLOCK = 1 * 1e18; uint256 constant PER_SHARE_SIZE = 1e12; // Info of each pool. struct PoolInfo { uint256 allocPoint; // How many allocation points assigned to this pool. SODAs to distribute per block. uint256 lastRewardBlock; // Last block number that SODAs distribution occurs. } // Info of each pool. mapping (address => PoolInfo) public poolMap; // By vault address. // pool length mapping (uint256 => address) public vaultMap; uint256 public poolLength; // Total allocation points. Must be the sum of all allocation points in all pools. uint256 public totalAllocPoint = 0; // The first block. uint256 public startBlock; // startBlock + ALL_BLOCKS_AMOUNT uint256 public endBlock; // The SODA Pool. SodaMaster public sodaMaster; mapping(address => uint256) private valuePerShare; // By vault. constructor( SodaMaster _sodaMaster ) public { sodaMaster = _sodaMaster; // Approve all. IERC20(sodaMaster.soda()).approve(sodaMaster.pool(), type(uint256).max); } // Admin calls this function. function setPoolInfo( uint256 _poolId, address _vault, IERC20 _token, uint256 _allocPoint, bool _withUpdate ) external onlyOwner { if (_withUpdate) { massUpdatePools(); } if (_poolId >= poolLength) { poolLength = _poolId + 1; } vaultMap[_poolId] = _vault; totalAllocPoint = totalAllocPoint.sub(poolMap[_vault].allocPoint).add(_allocPoint); poolMap[_vault].allocPoint = _allocPoint; _token.approve(sodaMaster.pool(), type(uint256).max); } // Admin calls this function. function approve(IERC20 _token) external override onlyOwner { _token.approve(sodaMaster.pool(), type(uint256).max); } // Return reward multiplier over the given _from to _to block. function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) { if (_to > endBlock) { _to = endBlock; } if (_from >= _to) { return 0; } return _to.sub(_from); } function getValuePerShare(address _vault) external view override returns(uint256) { return valuePerShare[_vault]; } function pendingValuePerShare(address _vault) external view override returns (uint256) { PoolInfo storage pool = poolMap[_vault]; uint256 amountInVault = IERC20(_vault).totalSupply(); if (block.number > pool.lastRewardBlock && amountInVault > 0) { uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number); uint256 sodaReward = multiplier.mul(SODA_PER_BLOCK).mul(pool.allocPoint).div(totalAllocPoint); sodaReward = sodaReward.sub(sodaReward.div(20)); return sodaReward.mul(PER_SHARE_SIZE).div(amountInVault); } else { return 0; } } // Update reward vairables for all pools. Be careful of gas spending! function massUpdatePools() public { for (uint256 i = 0; i < poolLength; ++i) { _update(vaultMap[i]); } } // Update reward variables of the given pool to be up-to-date. function _update(address _vault) public { PoolInfo storage pool = poolMap[_vault]; if (pool.allocPoint <= 0) { return; } if (pool.lastRewardBlock == 0) { // This is the first time that we start counting blocks. pool.lastRewardBlock = block.number; } if (block.number <= pool.lastRewardBlock) { return; } uint256 shareAmount = IERC20(_vault).totalSupply(); if (shareAmount == 0) { // Only after now >= pool.startTime in SodaPool, shareAmount can be larger than 0. return; } uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number); uint256 allReward = multiplier.mul(SODA_PER_BLOCK).mul(pool.allocPoint).div(totalAllocPoint); SodaToken(sodaMaster.soda()).mint(sodaMaster.dev(), allReward.div(20)); // 5% goes to dev. uint256 farmerReward = allReward.sub(allReward.div(20)); SodaToken(sodaMaster.soda()).mint(address(this), farmerReward); // 95% goes to farmers. valuePerShare[_vault] = valuePerShare[_vault].add(farmerReward.mul(PER_SHARE_SIZE).div(shareAmount)); pool.lastRewardBlock = block.number; } /** * @dev See {IStrategy-deposit}. */ function deposit(address _vault, uint256 _amount) external override { require(sodaMaster.isVault(msg.sender), "sender not vault"); if (startBlock == 0) { startBlock = block.number; endBlock = startBlock + ALL_BLOCKS_AMOUNT; } _update(_vault); } /** * @dev See {IStrategy-claim}. */ function claim(address _vault) external override { require(sodaMaster.isVault(msg.sender), "sender not vault"); _update(_vault); } /** * @dev See {IStrategy-withdraw}. */ function withdraw(address _vault, uint256 _amount) external override { require(sodaMaster.isVault(msg.sender), "sender not vault"); _update(_vault); } /** * @dev See {IStrategy-getTargetToken}. */ function getTargetToken() external view override returns(address) { return sodaMaster.soda(); } // This only happens after all the 100,000 tokens are minted, and should // be after the community can vote (I promise by then Timelock will // be administrated by GovernorAlpha). // // Community (of the future), please make sure _createMoreSoda contract is // safe enough to pull the trigger. function transferToCreateMoreSoda(address _createMoreSoda) external onlyOwner { require(block.number > endBlock); SodaToken(sodaMaster.soda()).transferOwnership(_createMoreSoda); } }
contract CreateSoda is IStrategy, Ownable { using SafeMath for uint256; uint256 public constant ALL_BLOCKS_AMOUNT = 100000; uint256 public constant SODA_PER_BLOCK = 1 * 1e18; uint256 constant PER_SHARE_SIZE = 1e12; // Info of each pool. struct PoolInfo { uint256 allocPoint; // How many allocation points assigned to this pool. SODAs to distribute per block. uint256 lastRewardBlock; // Last block number that SODAs distribution occurs. } // Info of each pool. mapping (address => PoolInfo) public poolMap; // By vault address. // pool length mapping (uint256 => address) public vaultMap; uint256 public poolLength; // Total allocation points. Must be the sum of all allocation points in all pools. uint256 public totalAllocPoint = 0; // The first block. uint256 public startBlock; // startBlock + ALL_BLOCKS_AMOUNT uint256 public endBlock; // The SODA Pool. SodaMaster public sodaMaster; mapping(address => uint256) private valuePerShare; // By vault. constructor( SodaMaster _sodaMaster ) public { sodaMaster = _sodaMaster; // Approve all. IERC20(sodaMaster.soda()).approve(sodaMaster.pool(), type(uint256).max); } // Admin calls this function. function setPoolInfo( uint256 _poolId, address _vault, IERC20 _token, uint256 _allocPoint, bool _withUpdate ) external onlyOwner { if (_withUpdate) { massUpdatePools(); } if (_poolId >= poolLength) { poolLength = _poolId + 1; } vaultMap[_poolId] = _vault; totalAllocPoint = totalAllocPoint.sub(poolMap[_vault].allocPoint).add(_allocPoint); poolMap[_vault].allocPoint = _allocPoint; _token.approve(sodaMaster.pool(), type(uint256).max); } // Admin calls this function. function approve(IERC20 _token) external override onlyOwner { _token.approve(sodaMaster.pool(), type(uint256).max); } // Return reward multiplier over the given _from to _to block. function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) { if (_to > endBlock) { _to = endBlock; } if (_from >= _to) { return 0; } return _to.sub(_from); } function getValuePerShare(address _vault) external view override returns(uint256) { return valuePerShare[_vault]; } function pendingValuePerShare(address _vault) external view override returns (uint256) { PoolInfo storage pool = poolMap[_vault]; uint256 amountInVault = IERC20(_vault).totalSupply(); if (block.number > pool.lastRewardBlock && amountInVault > 0) { uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number); uint256 sodaReward = multiplier.mul(SODA_PER_BLOCK).mul(pool.allocPoint).div(totalAllocPoint); sodaReward = sodaReward.sub(sodaReward.div(20)); return sodaReward.mul(PER_SHARE_SIZE).div(amountInVault); } else { return 0; } } // Update reward vairables for all pools. Be careful of gas spending! function massUpdatePools() public { for (uint256 i = 0; i < poolLength; ++i) { _update(vaultMap[i]); } } // Update reward variables of the given pool to be up-to-date. function _update(address _vault) public { PoolInfo storage pool = poolMap[_vault]; if (pool.allocPoint <= 0) { return; } if (pool.lastRewardBlock == 0) { // This is the first time that we start counting blocks. pool.lastRewardBlock = block.number; } if (block.number <= pool.lastRewardBlock) { return; } uint256 shareAmount = IERC20(_vault).totalSupply(); if (shareAmount == 0) { // Only after now >= pool.startTime in SodaPool, shareAmount can be larger than 0. return; } uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number); uint256 allReward = multiplier.mul(SODA_PER_BLOCK).mul(pool.allocPoint).div(totalAllocPoint); SodaToken(sodaMaster.soda()).mint(sodaMaster.dev(), allReward.div(20)); // 5% goes to dev. uint256 farmerReward = allReward.sub(allReward.div(20)); SodaToken(sodaMaster.soda()).mint(address(this), farmerReward); // 95% goes to farmers. valuePerShare[_vault] = valuePerShare[_vault].add(farmerReward.mul(PER_SHARE_SIZE).div(shareAmount)); pool.lastRewardBlock = block.number; } /** * @dev See {IStrategy-deposit}. */ function deposit(address _vault, uint256 _amount) external override { require(sodaMaster.isVault(msg.sender), "sender not vault"); if (startBlock == 0) { startBlock = block.number; endBlock = startBlock + ALL_BLOCKS_AMOUNT; } _update(_vault); } /** * @dev See {IStrategy-claim}. */ function claim(address _vault) external override { require(sodaMaster.isVault(msg.sender), "sender not vault"); _update(_vault); } /** * @dev See {IStrategy-withdraw}. */ function withdraw(address _vault, uint256 _amount) external override { require(sodaMaster.isVault(msg.sender), "sender not vault"); _update(_vault); } /** * @dev See {IStrategy-getTargetToken}. */ function getTargetToken() external view override returns(address) { return sodaMaster.soda(); } // This only happens after all the 100,000 tokens are minted, and should // be after the community can vote (I promise by then Timelock will // be administrated by GovernorAlpha). // // Community (of the future), please make sure _createMoreSoda contract is // safe enough to pull the trigger. function transferToCreateMoreSoda(address _createMoreSoda) external onlyOwner { require(block.number > endBlock); SodaToken(sodaMaster.soda()).transferOwnership(_createMoreSoda); } }
403
1
// ==================== METHODS ==================== /
constructor() ERC20Capped(OG_SUPPLY) ERC20("420OG", "420OG") { setTransferAllowed(false); }
constructor() ERC20Capped(OG_SUPPLY) ERC20("420OG", "420OG") { setTransferAllowed(false); }
44,170
16
// sort player cards first
for(uint i=0;i<player.cards.length;i++){ for(uint j=i+1;j<player.cards.length;j++){ if (player.cards[i].value > player.cards[j].value){ Card memory temp = player.cards[i]; player.cards[i] = player.cards[j]; player.cards[j] = temp; }
for(uint i=0;i<player.cards.length;i++){ for(uint j=i+1;j<player.cards.length;j++){ if (player.cards[i].value > player.cards[j].value){ Card memory temp = player.cards[i]; player.cards[i] = player.cards[j]; player.cards[j] = temp; }
28,583
5
// Rebalance version of `_totalSupplies`.
uint256 private _totalSupplyVersion;
uint256 private _totalSupplyVersion;
18,428
71
// manually batch update poolSig, called by core
function updatePoolSigs(bytes32[] calldata sigs, address[] calldata pools) external onlyCore
function updatePoolSigs(bytes32[] calldata sigs, address[] calldata pools) external onlyCore
33,950
9
// Chainlink: COMP/USD
return address(0xdbd020CAeF83eFd542f4De03e3cF0C28A4428bd5);
return address(0xdbd020CAeF83eFd542f4De03e3cF0C28A4428bd5);
7,648
45
// Create new token other then initial tokenAdd _value of token into _target account _target adress where new minted token to be created _value amount of token to be created/
function mintToken(address _target, uint256 _value) onlyOwner public returns(bool success){ require (_totalSupply <= ceilingSupply); _balanceOf[_target] = _balanceOf[_target].eadd(_value); _totalSupply = _totalSupply.eadd(_value); emit Transfer(address(0), _ownerAddress, _value); emit Transfer(_ownerAddress, _target, _value); return true; }
function mintToken(address _target, uint256 _value) onlyOwner public returns(bool success){ require (_totalSupply <= ceilingSupply); _balanceOf[_target] = _balanceOf[_target].eadd(_value); _totalSupply = _totalSupply.eadd(_value); emit Transfer(address(0), _ownerAddress, _value); emit Transfer(_ownerAddress, _target, _value); return true; }
15,867
45
// function will be called after user claims (ownership will be transfered)
function _resetPoints(address _address) external onlyOwner{ _stakedTokens[_address].points = 0; }
function _resetPoints(address _address) external onlyOwner{ _stakedTokens[_address].points = 0; }
37,530
123
// Gets the configuration paramters of the reserve self The reserve configurationreturn The state params representing ltv, liquidation threshold, liquidation bonus, the reserve decimals /
{ uint256 dataLocal = self.data; return ( dataLocal & ~LTV_MASK, (dataLocal & ~LIQUIDATION_THRESHOLD_MASK) >> LIQUIDATION_THRESHOLD_START_BIT_POSITION, (dataLocal & ~LIQUIDATION_BONUS_MASK) >> LIQUIDATION_BONUS_START_BIT_POSITION, (dataLocal & ~DECIMALS_MASK) >> RESERVE_DECIMALS_START_BIT_POSITION, (dataLocal & ~RESERVE_FACTOR_MASK) >> RESERVE_FACTOR_START_BIT_POSITION ); }
{ uint256 dataLocal = self.data; return ( dataLocal & ~LTV_MASK, (dataLocal & ~LIQUIDATION_THRESHOLD_MASK) >> LIQUIDATION_THRESHOLD_START_BIT_POSITION, (dataLocal & ~LIQUIDATION_BONUS_MASK) >> LIQUIDATION_BONUS_START_BIT_POSITION, (dataLocal & ~DECIMALS_MASK) >> RESERVE_DECIMALS_START_BIT_POSITION, (dataLocal & ~RESERVE_FACTOR_MASK) >> RESERVE_FACTOR_START_BIT_POSITION ); }
8,758
75
// mint NYTs and PYTs
nyt.gateMint(nytRecipient, yieldAmount); if (address(xPYT) == address(0)) {
nyt.gateMint(nytRecipient, yieldAmount); if (address(xPYT) == address(0)) {
4,012
159
// Returns the subtraction of two unsigned integers, reverting with custom message on overflow (when the result is negative). Counterpart to Solidity's `-` operator. Requirements: - Subtraction cannot overflow. NOTE: This is a feature of the next version of OpenZeppelin Contracts.Get it via `npm install @openzeppelin/contracts@next`./
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; }
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; }
18,066
74
// Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to`approved`. /
event ApprovalForAll(address indexed account, address indexed operator, bool approved);
event ApprovalForAll(address indexed account, address indexed operator, bool approved);
7,548
24
// Moves `amount` of tokens from `from` to `to`.
* This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. */ function _transfer( address from, address to, uint256 amount ) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(from, to, amount); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by // decrementing then incrementing. _balances[to] += amount; } emit Transfer(from, to, amount); _afterTokenTransfer(from, to, amount); }
* This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. */ function _transfer( address from, address to, uint256 amount ) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(from, to, amount); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by // decrementing then incrementing. _balances[to] += amount; } emit Transfer(from, to, amount); _afterTokenTransfer(from, to, amount); }
8,171
5
// check balance - total balance should be greater than the total supply for the coin
uint256 balance = usdcToken.balanceOf(_account); require(balance>=tokenMetaData[_tokenId].totalSupply, "Balance is not enough, please make sure you have USDC");
uint256 balance = usdcToken.balanceOf(_account); require(balance>=tokenMetaData[_tokenId].totalSupply, "Balance is not enough, please make sure you have USDC");
35,361
1
// Pauser role identifier
bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
59,814
40
// ✅Delete tasks with no submissions Get tasks with no submissions
uint256[] memory noneTasksInProject = Iupmas(updateMasterAddress) .getNoneTasksIDs(_projectID); for (uint256 i = 0; i < noneTasksInProject.length; i++) {
uint256[] memory noneTasksInProject = Iupmas(updateMasterAddress) .getNoneTasksIDs(_projectID); for (uint256 i = 0; i < noneTasksInProject.length; i++) {
15,986
2
// return the sender of this call.if the call came through our trusted forwarder, then the real sender is appended as the last 20 bytesof the msg.data.otherwise, return `msg.sender`should be used in the contract anywhere instead of msg.sender /
function _msgSender() internal view virtual returns (address payable); function versionRecipient() external view virtual returns (string memory);
function _msgSender() internal view virtual returns (address payable); function versionRecipient() external view virtual returns (string memory);
6,213
170
// return The current feesAccrued counter
function feesAccrued() external view returns (uint256);
function feesAccrued() external view returns (uint256);
34,564
396
// Returns the number of decimals used to get its user representation. For example, if `decimals` equals `2`, a balance of `505` tokens should be displayed to a user as `5,05` (`505 / 102`).Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * @dev NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. * * @return token decimals */ // OPTIONAL - This method can be used to improve usability, // but interfaces and other contracts MUST NOT expect these values to be present. // function decimals() external view returns (uint8); /** * @return the amount of tokens in existence */ function totalSupply() external view returns (uint256); /** * @notice Gets the balance of a particular address * * @param _owner the address to query the the balance for * @return balance an amount of tokens owned by the address specified */ function balanceOf(address _owner) external view returns (uint256 balance); /** * @notice Transfers some tokens to an external address or a smart contract * * @dev Called by token owner (an address which has a * positive token balance tracked by this smart contract) * @dev Throws on any error like * * insufficient token balance or * * incorrect `_to` address: * * zero address or * * self address or * * smart contract which doesn't support ERC20 * * @param _to an address to transfer tokens to, * must be either an external address or a smart contract, * compliant with the ERC20 standard * @param _value amount of tokens to be transferred,, zero * value is allowed * @return success true on success, throws otherwise */ function transfer(address _to, uint256 _value) external returns (bool success); /** * @notice Transfers some tokens on behalf of address `_from' (token owner) * to some other address `_to` * * @dev Called by token owner on his own or approved address, * an address approved earlier by token owner to * transfer some amount of tokens on its behalf * @dev Throws on any error like * * insufficient token balance or * * incorrect `_to` address: * * zero address or * * same as `_from` address (self transfer) * * smart contract which doesn't support ERC20 * * @param _from token owner which approved caller (transaction sender) * to transfer `_value` of tokens on its behalf * @param _to an address to transfer tokens to, * must be either an external address or a smart contract, * compliant with the ERC20 standard * @param _value amount of tokens to be transferred,, zero * value is allowed * @return success true on success, throws otherwise */ function transferFrom(address _from, address _to, uint256 _value) external returns (bool success); /** * @notice Approves address called `_spender` to transfer some amount * of tokens on behalf of the owner (transaction sender) * * @dev Transaction sender must not necessarily own any tokens to grant the permission * * @param _spender an address approved by the caller (token owner) * to spend some tokens on its behalf * @param _value an amount of tokens spender `_spender` is allowed to * transfer on behalf of the token owner * @return success true on success, throws otherwise */ function approve(address _spender, uint256 _value) external returns (bool success); /** * @notice Returns the amount which _spender is still allowed to withdraw from _owner. * * @dev A function to check an amount of tokens owner approved * to transfer on its behalf by some other address called "spender" * * @param _owner an address which approves transferring some tokens on its behalf * @param _spender an address approved to transfer some tokens on behalf * @return remaining an amount of tokens approved address `_spender` can transfer on behalf * of token owner `_owner` */ function allowance(address _owner, address _spender) external view returns (uint256 remaining); }
* Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * @dev NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. * * @return token decimals */ // OPTIONAL - This method can be used to improve usability, // but interfaces and other contracts MUST NOT expect these values to be present. // function decimals() external view returns (uint8); /** * @return the amount of tokens in existence */ function totalSupply() external view returns (uint256); /** * @notice Gets the balance of a particular address * * @param _owner the address to query the the balance for * @return balance an amount of tokens owned by the address specified */ function balanceOf(address _owner) external view returns (uint256 balance); /** * @notice Transfers some tokens to an external address or a smart contract * * @dev Called by token owner (an address which has a * positive token balance tracked by this smart contract) * @dev Throws on any error like * * insufficient token balance or * * incorrect `_to` address: * * zero address or * * self address or * * smart contract which doesn't support ERC20 * * @param _to an address to transfer tokens to, * must be either an external address or a smart contract, * compliant with the ERC20 standard * @param _value amount of tokens to be transferred,, zero * value is allowed * @return success true on success, throws otherwise */ function transfer(address _to, uint256 _value) external returns (bool success); /** * @notice Transfers some tokens on behalf of address `_from' (token owner) * to some other address `_to` * * @dev Called by token owner on his own or approved address, * an address approved earlier by token owner to * transfer some amount of tokens on its behalf * @dev Throws on any error like * * insufficient token balance or * * incorrect `_to` address: * * zero address or * * same as `_from` address (self transfer) * * smart contract which doesn't support ERC20 * * @param _from token owner which approved caller (transaction sender) * to transfer `_value` of tokens on its behalf * @param _to an address to transfer tokens to, * must be either an external address or a smart contract, * compliant with the ERC20 standard * @param _value amount of tokens to be transferred,, zero * value is allowed * @return success true on success, throws otherwise */ function transferFrom(address _from, address _to, uint256 _value) external returns (bool success); /** * @notice Approves address called `_spender` to transfer some amount * of tokens on behalf of the owner (transaction sender) * * @dev Transaction sender must not necessarily own any tokens to grant the permission * * @param _spender an address approved by the caller (token owner) * to spend some tokens on its behalf * @param _value an amount of tokens spender `_spender` is allowed to * transfer on behalf of the token owner * @return success true on success, throws otherwise */ function approve(address _spender, uint256 _value) external returns (bool success); /** * @notice Returns the amount which _spender is still allowed to withdraw from _owner. * * @dev A function to check an amount of tokens owner approved * to transfer on its behalf by some other address called "spender" * * @param _owner an address which approves transferring some tokens on its behalf * @param _spender an address approved to transfer some tokens on behalf * @return remaining an amount of tokens approved address `_spender` can transfer on behalf * of token owner `_owner` */ function allowance(address _owner, address _spender) external view returns (uint256 remaining); }
50,268
124
// Addresses of supported tokens
IERC20 sos;
IERC20 sos;
38,605
54
// Effects
emit OwnershipTransferred(owner, newOwner); owner = newOwner; pendingOwner = address(0);
emit OwnershipTransferred(owner, newOwner); owner = newOwner; pendingOwner = address(0);
1,107
24
// enables users to stake stable coins/ YFMS from their respective vaults. called from vaults.
function stake(string memory _vault, address _receiver, uint256 _amount, address vault) public returns (bool) { require(msg.sender == vault); // require that the vault is calling the contract. // update mapping. vaults_data[_vault][_receiver] = vaults_data[_vault][_receiver].add(_amount); return true; }
function stake(string memory _vault, address _receiver, uint256 _amount, address vault) public returns (bool) { require(msg.sender == vault); // require that the vault is calling the contract. // update mapping. vaults_data[_vault][_receiver] = vaults_data[_vault][_receiver].add(_amount); return true; }
75,905
161
// require(collections[owner] == address(0), "already owns collection");no need this check
Collection cl = new Collection(name_, symbol_, msg.sender); // creating collection and setting its XanaliaDex as its owner (who can only mint new NFTs of this collection on the request of user (this logic to be done in xanaliaDEX contract)) collections[owner_].push(address(cl)); emit CollectionCreated(owner_, address(cl), name_, symbol_); return address(cl);
Collection cl = new Collection(name_, symbol_, msg.sender); // creating collection and setting its XanaliaDex as its owner (who can only mint new NFTs of this collection on the request of user (this logic to be done in xanaliaDEX contract)) collections[owner_].push(address(cl)); emit CollectionCreated(owner_, address(cl), name_, symbol_); return address(cl);
6,735
3
// The main controller logic for 'piggybackInFlightExitOnInput' emits InFlightExitInputPiggybacked event on success self the controller struct inFlightExitMap the storage of all in-flight exit data args arguments of 'piggybackInFlightExitOnInput' function from client. /
function piggybackInput( Controller memory self, PaymentExitDataModel.InFlightExitMap storage inFlightExitMap, PaymentInFlightExitRouterArgs.PiggybackInFlightExitOnInputArgs memory args ) public
function piggybackInput( Controller memory self, PaymentExitDataModel.InFlightExitMap storage inFlightExitMap, PaymentInFlightExitRouterArgs.PiggybackInFlightExitOnInputArgs memory args ) public
33,283
217
// Returning Residue in token0, if any.
if (token0Bought - amountA > 0) { IERC20(_ToUnipoolToken0).safeTransfer( msg.sender, token0Bought - amountA ); }
if (token0Bought - amountA > 0) { IERC20(_ToUnipoolToken0).safeTransfer( msg.sender, token0Bought - amountA ); }
16,281
16
// Move voting power when tokens are transferred.
* Emits a {IVotes-DelegateVotesChanged} event. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual override { super._afterTokenTransfer(from, to, amount); _moveVotingPower(delegates(from), delegates(to), amount); }
* Emits a {IVotes-DelegateVotesChanged} event. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual override { super._afterTokenTransfer(from, to, amount); _moveVotingPower(delegates(from), delegates(to), amount); }
22,226
84
// emit the creaton event
emit NewCRLToken( _owner, TOKEN_UUID, _traits );
emit NewCRLToken( _owner, TOKEN_UUID, _traits );
48,466
11
// get winner id
uint winnerId = _rand(0, 399); lastWinnerId = winnerId;
uint winnerId = _rand(0, 399); lastWinnerId = winnerId;
54,126
69
// LumosToken
contract LumosToken is ERC20("Lumos", "LMS"), Ownable { /// @notice Creates `_amount` token to `_to`. Must only be called by the owner function mint(address _to, uint256 _amount) public onlyOwner { _mint(_to, _amount); } }
contract LumosToken is ERC20("Lumos", "LMS"), Ownable { /// @notice Creates `_amount` token to `_to`. Must only be called by the owner function mint(address _to, uint256 _amount) public onlyOwner { _mint(_to, _amount); } }
18,550
134
// NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}. /
function upgradeTo(address newImplementation) external ifAdmin { _upgradeTo(newImplementation); }
function upgradeTo(address newImplementation) external ifAdmin { _upgradeTo(newImplementation); }
35,040
20
// Goal is for (askDenominator / askNumerator) > (bestBid.pay_amt / bestBid.buy_amt)
require( (askD.mul(bestBid.buy_amt)) > (bestBid.pay_amt.mul(askN)), "ask price not greater than best bid" );
require( (askD.mul(bestBid.buy_amt)) > (bestBid.pay_amt.mul(askN)), "ask price not greater than best bid" );
16,512
130
// Function to mint tokens. to The address that will receive the minted token. tokenId The token id to mint.return A boolean that indicates if the operation was successful. /
function mint(address to, uint256 tokenId) public onlyMinter returns (bool) { _mint(to, tokenId); return true; }
function mint(address to, uint256 tokenId) public onlyMinter returns (bool) { _mint(to, tokenId); return true; }
7,591
19
// token owner cannot perform this operation.Signature : `0xf08f1926`
error TokenOwnerNotAllowed();
error TokenOwnerNotAllowed();
29,074
32
// See the current token price in wei (https:etherconverter.online to convert to other units, such as ETH)
function price() constant returns (uint) { return sellPrice; }
function price() constant returns (uint) { return sellPrice; }
34,983
10
// Pause the smart contract. Only can be called by the CEO
function pause() public onlyCEO whenNotPaused { paused = true; }
function pause() public onlyCEO whenNotPaused { paused = true; }
8,767
114
// The block number when Zcdw 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( zcdwERC20 _zcdw, address _devaddr, uint256 _zcdwPerBlock,
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( zcdwERC20 _zcdw, address _devaddr, uint256 _zcdwPerBlock,
5,151
80
// redeemUnderlying(uint256 _underlyingAmount)
bytes memory redeemCallData = abi.encodeWithSignature("redeemUnderlying(uint256)", _redeemNotional); require( abi.decode(_setToken.invoke(_cToken, 0, redeemCallData), (uint256)) == 0, "Redeem failed" ); if (_cToken == cEther) { _setToken.invokeWrapWETH(weth, _redeemNotional); }
bytes memory redeemCallData = abi.encodeWithSignature("redeemUnderlying(uint256)", _redeemNotional); require( abi.decode(_setToken.invoke(_cToken, 0, redeemCallData), (uint256)) == 0, "Redeem failed" ); if (_cToken == cEther) { _setToken.invokeWrapWETH(weth, _redeemNotional); }
30,933
37
// default to DEFAULT setting if ZERO value
function getAppConfig(uint16 _chainId, address userApplicationAddress) public view returns (ApplicationConfiguration memory) { ApplicationConfiguration memory config = appConfig[userApplicationAddress][_chainId]; ApplicationConfiguration storage defaultConfig = defaultAppConfig[_chainId]; if (config.inboundProofLibraryVersion == 0) { config.inboundProofLibraryVersion = defaultConfig.inboundProofLibraryVersion; } if (config.inboundBlockConfirmations == 0) { config.inboundBlockConfirmations = defaultConfig.inboundBlockConfirmations; } if (config.relayer == address(0x0)) { config.relayer = defaultConfig.relayer; } if (config.outboundProofType == 0) { config.outboundProofType = defaultConfig.outboundProofType; } if (config.outboundBlockConfirmations == 0) { config.outboundBlockConfirmations = defaultConfig.outboundBlockConfirmations; } if (config.oracle == address(0x0)) { config.oracle = defaultConfig.oracle; } return config; }
function getAppConfig(uint16 _chainId, address userApplicationAddress) public view returns (ApplicationConfiguration memory) { ApplicationConfiguration memory config = appConfig[userApplicationAddress][_chainId]; ApplicationConfiguration storage defaultConfig = defaultAppConfig[_chainId]; if (config.inboundProofLibraryVersion == 0) { config.inboundProofLibraryVersion = defaultConfig.inboundProofLibraryVersion; } if (config.inboundBlockConfirmations == 0) { config.inboundBlockConfirmations = defaultConfig.inboundBlockConfirmations; } if (config.relayer == address(0x0)) { config.relayer = defaultConfig.relayer; } if (config.outboundProofType == 0) { config.outboundProofType = defaultConfig.outboundProofType; } if (config.outboundBlockConfirmations == 0) { config.outboundBlockConfirmations = defaultConfig.outboundBlockConfirmations; } if (config.oracle == address(0x0)) { config.oracle = defaultConfig.oracle; } return config; }
36,184
46
// If there aren't enough tokens available, give what is available.
uint max_amt = address(this).tokenBalance(tokenId); if (max_amt < amount) amount = max_amt; if (amount > 0) { balance[msg.sender] = balance[msg.sender] - amount; msg.sender.transferToken(amount, tokenId); reserved = reserved - amount; totalGiven += int(amount); }
uint max_amt = address(this).tokenBalance(tokenId); if (max_amt < amount) amount = max_amt; if (amount > 0) { balance[msg.sender] = balance[msg.sender] - amount; msg.sender.transferToken(amount, tokenId); reserved = reserved - amount; totalGiven += int(amount); }
23,408