ERC-20
Overview
Max Total Supply
148,063.933750000000000649 PS
Holders
662
Market
Price
$0.00 @ 0.000000 MATIC
Onchain Market Cap
$0.00
Circulating Supply Market Cap
-
Other Info
Token Contract (WITH 18 Decimals)
Balance
2.25 PSValue
$0.00Loading...
Loading
Loading...
Loading
Loading...
Loading
Minimal Proxy Contract for 0x1555eccb045f3c2858b1f779949f86ebbf0b365f
Contract Name:
VestingToken
Compiler Version
v0.8.18+commit.87f61d96
Optimization Enabled:
Yes with 10000 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.18; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {Initializable} from "@oz-upgradeable/contracts/proxy/utils/Initializable.sol"; import {ERC20Upgradeable} from "@oz-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol"; import {Vesting, Schedule} from "./interfaces/IVestingToken.sol"; import {IERC20Burnable} from "./interfaces/IERC20Burnable.sol"; import {IERC721Mint} from "./interfaces/IERC721Mint.sol"; /** * @title VestingToken * @notice VestingToken contract handles token vesting functionality. * Base tokens are initially locked and then gradually released over time * according to a vesting schedule. * It is possible to run a token burning round in which vesting tokens * and an equivalent number of base tokens are burned in exchange for nft. */ contract VestingToken is Initializable, ERC20Upgradeable { using SafeERC20 for IERC20Burnable; /// @notice The factor used to calculate percentages for the vesting schedule. /// It is set to 10_000 to handle basis points (0.01% increments) uint256 private constant BASIS_POINTS = 10_000; /// @notice Address of the party that is minting the tokens. address private s_minter; /// @notice The address of the VestingManager contract. /// This contract is responsible for creating new VestingToken contracts address private s_vestingManager; /// @notice The token that is being vested IERC20Burnable private s_baseToken; /// @notice Vesting schedule for the vested tokens Vesting private s_vesting; /// @notice Initial amount of tokens subject to vesting uint256 private s_initialLockedSupply; /// @notice Struct representing a burning round for a vesting token struct BurningRound { address nft; uint256 startTime; uint256 endTime; uint256 totalToBurn; uint256 minBurnPerTx; uint256 maxBurnPerTx; uint256 totalBurned; } /// @notice The variable holds the information about the currently active burning round BurningRound private s_burningRound; constructor() { _disableInitializers(); } /// @notice Returns the initial amount of tokens locked for a given address mapping(address => uint256) private s_initialLocked; /// @notice Returns the amount of tokens already released for a given address mapping(address => uint256) private s_released; // region - Errors ///////////////////// // Errors // ///////////////////// /// @notice When an action tries to execute an address that is not allowed to mint tokens error OnlyMinter(); /// @notice When an action is attempted by non-vesting manager error OnlyVestingManager(); /// @notice When vesting has not started yet error VestingNotStarted(); /// @notice When the cliff period has not ended yet error CliffNotEnded(); /// @notice When there aren't enough tokens to claim error NotEnoughTokensToClaim(); /// @notice When the vesting start time has already passed error StartTimeAlreadyElapsed(); /// @notice When the cliff is set to be before the vesting start time error CliffBeforeStartTime(); /// @notice When the vesting schedule's portions do not add up to 100% error IncorrectSchedulePortions(); /// @notice When the vesting schedule time order is incorrect error IncorrectScheduleTime(uint256 incorrectTime); /// @notice When token transfers are not allowed error TransfersNotAllowed(); /// @notice When the startTime or endTime for burning round is incorrect error IncorrectBurningRoundTime(); /// @notice When the specified burning round limits are incorrect or invalid error IncorrectBurningRoundLimits(); /// @notice When an action is attempted with a zero parameter that must be non-zero error ZeroParam(); /// @notice When an action is attempted involving a zero address error ZeroAddress(); /// @notice When an attempt is made to burn tokens at an unspecified time error BurningRoundMustBeActive(); /// @notice When an attempt is made to burn tokens in a round /// that has either already ended or has not yet begun error BurningRoundIsOverOrNotStarted(); /// @notice When an action is attempted with a value that is less than the minimum limit error LessThanMinLimit(); /// @notice When an action is attempted with a value that is more than the maximum limit error MoreThenMaxLimit(); /// @notice When minting tokens is attempted after the cliff period, which is not allowed error MintingAfterCliffIsForbidden(); // endregion // region - Events ///////////////////// // Events // ///////////////////// /// @notice Emitted when a vesting schedule is set for the contract event VestingScheduleSet(Vesting vesting); /// @notice Emitted when tokens are released to a beneficiary event Released(address indexed beneficiary, uint256 amount); /// @notice Emitted when tokens are locked upon purchase by a buyer event Locked( address indexed buyer, address indexed vestingToken, uint256 amount, Vesting vestingSchedule ); /// @notice Emitted when a new burning round is created event BurningRoundCreated(BurningRound); /// @notice Emitted when the address of the NFT contract is set event NftAddressSet(address nft); /// @notice Emitted when an NFT is minted event NftMinted(address indexed holder, uint256 tokenId, uint256 amountOfTokens); // endregion // region - Modifiers /// @dev Allow only the minter to perform certain operations modifier onlyMinter() { if (msg.sender != s_minter) { revert OnlyMinter(); } _; } /// @notice Allow only the vesting manager to perform certain operations modifier onlyVestingManager() { if (msg.sender != s_vestingManager) { revert OnlyVestingManager(); } _; } // endregion // region - Initialize /** * @notice Initializes the vesting token with the provided parameters * @param name The name of the token * @param symbol The symbol of the token * @param minter The address of the minter * @param baseToken The token to be vested * @dev This function should be called only once */ function initialize( string calldata name, string calldata symbol, address minter, address baseToken ) public initializer { if (minter == address(0) || baseToken == address(0)) { revert ZeroAddress(); } __ERC20_init(name, symbol); s_minter = minter; s_baseToken = IERC20Burnable(baseToken); s_vestingManager = msg.sender; } // endregion // region - Set vesting schedule /** * @notice Sets the vesting schedule for the token * @param startTime The start time of the vesting schedule in UNIX timestamp * @param cliff The UNIX timestamp when the first portion is vested * @param schedule An array of Schedule structs that represent the vesting schedule * @dev Can only be called by the vesting manager. * Also checks the validity of the vesting schedule before setting it. * Emits a VestingScheduleSet event after setting the vesting schedule. */ function setVestingSchedule( uint256 startTime, uint256 cliff, Schedule[] calldata schedule ) external onlyVestingManager { uint256 scheduleLength = schedule.length; _checkVestingSchedule(startTime, cliff, schedule, scheduleLength); s_vesting.startTime = startTime; s_vesting.cliff = cliff; for (uint256 i = 0; i < scheduleLength; i++) { s_vesting.schedule.push(schedule[i]); } emit VestingScheduleSet(s_vesting); } /** * @notice Validates the provided vesting schedule * @dev Checks if start time is not in the past, start time is before cliff, * vesting schedule times are in order and not before the cliff, and the total * portions in the schedule equals to 100% (BASIS_POINTS). */ function _checkVestingSchedule( uint256 startTime, uint256 cliff, Schedule[] calldata schedule, uint256 scheduleLength ) private view { if (startTime < block.timestamp) { revert StartTimeAlreadyElapsed(); } if (startTime > cliff) { revert CliffBeforeStartTime(); } // Variable to keep track of the total percentage of the vesting schedule uint256 totalPercent; for (uint256 i = 0; i < scheduleLength; i++) { totalPercent += schedule[i].portion; // Check if the end times of the vesting schedule are in order bool isEndTimeOutOfOrder = (i != 0) && schedule[i - 1].endTime >= schedule[i].endTime; // Check if the cliff is after the end time of the current portion // or if the end times are out of order if (cliff >= schedule[i].endTime || isEndTimeOutOfOrder) { revert IncorrectScheduleTime(schedule[i].endTime); } } if (totalPercent != BASIS_POINTS) { revert IncorrectSchedulePortions(); } } // endregion // region - Mint /** * @notice Mints new vesting tokens to the specified address, * locks the corresponding amount of base tokens * @param to The address to receive the newly minted tokens * @param amount The amount of tokens to be minted and locked * @dev Only callable by the minter. * The base tokens are transferred from the minter to this contract * Emits a Locked event indicating that tokens have been locked with a vesting schedule */ function mint(address to, uint256 amount) external onlyMinter { if (block.timestamp >= s_vesting.cliff) { revert MintingAfterCliffIsForbidden(); } // Transfer base tokens from the minter to this contract s_baseToken.safeTransferFrom(msg.sender, address(this), amount); // Mint vesting tokens to the specified address _mint(to, amount); s_initialLocked[to] += amount; s_initialLockedSupply += amount; emit Locked(to, address(this), amount, getVestingSchedule()); } // endregion // region - Claim /** * @notice Claims releasable tokens from the vesting contract * and transfers them to the caller * @dev The caller must be a beneficiary of the vesting schedule. * Tokens are only claimable after the cliff period has passed. * Emits a Released event indicating the release of tokens to the caller. */ function claim() external { Vesting memory vesting = s_vesting; if (vesting.startTime == 0) { revert VestingNotStarted(); } if (block.timestamp < vesting.cliff) { revert CliffNotEnded(); } uint256 releasable = availableBalanceOf(msg.sender); // Ensure that there are releasable tokens if (releasable == 0) { revert NotEnoughTokensToClaim(); } s_released[msg.sender] += releasable; // Burn the claimed tokens from the caller's balance _burn(msg.sender, releasable); // Transfer the claimed tokens to the caller s_baseToken.safeTransfer(msg.sender, releasable); emit Released(msg.sender, releasable); } /** * @notice Claims an NFT by burning the specified amount of tokens * @param amount The amount of tokens to be burned in order to claim the NFT * @dev The number of tokens burned will be reflected in the total tokens burned * in the current burning round. The base token will also be burned. * If the current timestamp is before the vesting cliff, * the initial locked balance will be updated. * An NFT will be minted and assigned to the sender. * Emits an NftMinted event with the sender address, * token identifier nft and number of tokens burned. */ function claimNft(uint256 amount) external { _preValidateBurning(amount); // Update total burned tokens in the current burning round s_burningRound.totalBurned += amount; // Burn tokens from the sender's balance _burn(msg.sender, amount); // Burn base token s_baseToken.burn(amount); // Update initial locked balance if the current timestamp is before the vesting cliff if (block.timestamp < s_vesting.cliff) { _updateInitialLocked(amount); } // Mint NFT and indicate the number of tokens burned uint256 tokenId = IERC721Mint(s_burningRound.nft).mint(msg.sender, amount); emit NftMinted(msg.sender, tokenId, amount); } /** * @notice Performs pre-validation checks before executing the burning of tokens * @dev The function checks if the current burning round is active * and if the specified amount is within the allowed limits. * It also verifies that the burning round is not over or has not started yet. * Throws specific errors to indicate the validation failures. */ function _preValidateBurning(uint256 amount) private view { BurningRound memory round = s_burningRound; // Check if the burning round is active if (round.endTime == 0 || round.endTime < block.timestamp) { revert BurningRoundMustBeActive(); } // Check if the burning round is over or not started yet if (round.totalBurned >= round.totalToBurn) { revert BurningRoundIsOverOrNotStarted(); } // Check if the amount is less than the minimum burn limit if (amount < round.minBurnPerTx) { revert LessThanMinLimit(); } // Check if the amount exceeds the maximum burn limit or the remaining tokens to burn if ( amount > round.maxBurnPerTx || amount > (round.totalToBurn - round.totalBurned) ) { revert MoreThenMaxLimit(); } } /** * @notice Updates the initial locked balance after burning tokens before the vesting cliff * @dev This function is used to update the initial locked balance * of the sender's account by deducting the specified amount. * It also updates the overall initial locked supply by deducting the specified amount. * Performs assertions to verify the consistency of the updated balances. */ function _updateInitialLocked(uint256 amount) private { unchecked { s_initialLocked[msg.sender] -= amount; s_initialLockedSupply -= amount; } assert(balanceOf(msg.sender) == s_initialLocked[msg.sender]); assert(totalSupply() == s_initialLockedSupply); } // endregion // region - Burning round /** * @notice Creates a new burning round for vesting tokens * @param nft The address of the NFT contract associated with the burning round * @param startTime The starting time of the burning round * @param endTime The ending time of the burning round * @param totalToBurn The total amount of tokens to be burned in the round * @param minBurnPerTx The minimum amount of tokens that can be burned per transaction * @param maxBurnPerTx The maximum amount of tokens that can be burned per transaction * @dev Performs parameter checks to ensure the validity of the burning round. * Updates the state with the new burning round information. * Emits a BurningRoundCreated event after creating the burning round. */ function createBurningRound( address nft, uint256 startTime, uint256 endTime, uint256 totalToBurn, uint256 minBurnPerTx, uint256 maxBurnPerTx ) external onlyVestingManager { if (nft == address(0)) { revert ZeroAddress(); } _checkBurningParams(startTime, endTime, totalToBurn, minBurnPerTx, maxBurnPerTx); s_burningRound = BurningRound( nft, startTime, endTime, totalToBurn, minBurnPerTx, maxBurnPerTx, 0 ); emit BurningRoundCreated(s_burningRound); } /** * @notice Performs parameter checks for a burning round * @dev Throws an error if the parameters are invalid * or do not satisfy the required conditions. * The function checks the validity of the start and end times, * the non-zero values of parameters, * and the correctness of the burn limits. */ function _checkBurningParams( uint256 startTime, uint256 endTime, uint256 totalToBurn, uint256 minBurnPerTx, uint256 maxBurnPerTx ) private view { if (startTime < block.timestamp || startTime >= endTime) { revert IncorrectBurningRoundTime(); } if (totalToBurn == 0 || minBurnPerTx == 0 || maxBurnPerTx == 0) { revert ZeroParam(); } if (minBurnPerTx > maxBurnPerTx || maxBurnPerTx > totalToBurn) { revert IncorrectBurningRoundLimits(); } } /** * @notice Stops the currently active burning round * @dev Sets the end time of the burning round to zero, effectively stopping it */ function stopBurningRound() external onlyVestingManager { s_burningRound.endTime = 0; } // endregion // region - Getters /// @notice Returns the address of the minter function getMinter() external view returns (address) { return s_minter; } /// @notice Returns the address of the base token function getBaseToken() external view returns (address) { return address(s_baseToken); } /// @notice Returns the vesting schedule associated with this vesting token function getVestingSchedule() public view returns (Vesting memory) { return s_vesting; } /// @notice Returns the parameters of the currently active burning round function getBurningRoundParams() public view returns (BurningRound memory) { return s_burningRound; } /// @notice Returns the current supply of initial locked tokens function getInitialLockedSupply() public view returns (uint256) { return s_initialLockedSupply; } // endregion // region - Vesting getters /// @notice Returns the total supply of unlocked tokens function unlockedSupply() external view returns (uint256) { return _totalUnlocked(); } /// @notice Returns the total supply of locked tokens function lockedSupply() external view returns (uint256) { return s_initialLockedSupply - _totalUnlocked(); } /// @notice Returns the available balance of tokens for a specified account function availableBalanceOf( address account ) public view returns (uint256 releasable) { releasable = _unlockedOf(account) - s_released[account]; // Check if the available balance exceeds the current balance if (releasable > balanceOf(account)) { // Return the current balance if the releasable amount is higher return balanceOf(account); } } // endregion // region - Private functions /// @notice Returns the amount of unlocked tokens for a specific account function _unlockedOf(address account) private view returns (uint256) { return _computeUnlocked(s_initialLocked[account], block.timestamp); } /// @notice Returns the total amount of unlocked tokens function _totalUnlocked() private view returns (uint256) { return _computeUnlocked(s_initialLockedSupply, block.timestamp); } /** * @notice Computes the amount of unlocked tokens based on the lockedTokens * and the specified time * @param lockedTokens The amount of locked tokens * @param time The time for which to compute the unlocked tokens * @return unlockedTokens The amount of unlocked tokens at the specified time */ function _computeUnlocked( uint256 lockedTokens, uint256 time ) private view returns (uint256 unlockedTokens) { if (time < s_vesting.cliff) { return 0; } uint256 currentPeriodStart = s_vesting.cliff; Schedule[] memory schedule = s_vesting.schedule; uint256 scheduleLength = schedule.length; // Iterate through each period in the vesting schedule for (uint256 i = 0; i < scheduleLength; i++) { Schedule memory currentPeriod = schedule[i]; uint256 currentPeriodEnd = currentPeriod.endTime; uint256 currentPeriodPortion = currentPeriod.portion; // If the current time is before the end of the current period if (time < currentPeriodEnd) { uint256 elapsedPeriodTime = time - currentPeriodStart; uint256 periodDuration = currentPeriodEnd - currentPeriodStart; // Calculate the unlocked tokens based on the elapsed time within the period unlockedTokens += (lockedTokens * elapsedPeriodTime * currentPeriodPortion) / (periodDuration * BASIS_POINTS); // Exit the loop since the unlocked tokens for the current period // have been calculated break; } else { // All tokens for the current period are unlocked unlockedTokens += (lockedTokens * currentPeriodPortion) / BASIS_POINTS; // Update the start time of the next period currentPeriodStart = currentPeriodEnd; } } } /** * @notice Performs additional checks before token transfer * @dev Allow only minting and burning operations */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal override { super._beforeTokenTransfer(from, to, amount); if (from != address(0) && to != address(0)) { revert TransfersNotAllowed(); } } // endregion }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../extensions/draft-IERC20Permit.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } function safePermit( IERC20Permit token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ```solidity * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a * constructor. * * Emits an {Initialized} event. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: setting the version to 255 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized != type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint8) { return _initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _initializing; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; import "./IERC20Upgradeable.sol"; import "./extensions/IERC20MetadataUpgradeable.sol"; import "../../utils/ContextUpgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * The default value of {decimals} is 18. To change this, you should override * this function so it returns a different value. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * 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 ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * All two of these values are immutable: they can only be set once during * construction. */ function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing { __ERC20_init_unchained(name_, symbol_); } function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev 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 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the default value returned by this function, unless * it's overridden. * * 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}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address to, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, allowance(owner, spender) + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { address owner = _msgSender(); uint256 currentAllowance = allowance(owner, spender); require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(owner, spender, currentAllowance - subtractedValue); } return true; } /** * @dev 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); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; unchecked { // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above. _balances[account] += amount; } emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; // Overflow not possible: amount <= accountBalance <= totalSupply. _totalSupply -= amount; } emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Updates `owner` s allowance for `spender` based on spent `amount`. * * Does not update the allowance amount in case of infinite allowance. * Revert if not enough allowance is available. * * Might emit an {Approval} event. */ function _spendAllowance(address owner, address spender, uint256 amount) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {} /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[45] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.18; struct Schedule { uint256 endTime; uint256 portion; } struct Vesting { uint256 startTime; uint256 cliff; Schedule[] schedule; } interface IVestingToken { function initialize( string calldata name, string calldata symbol, address minter, address token ) external; function setVestingSchedule( uint256 startTime, uint256 cliff, Schedule[] calldata schedule ) external; function mint(address to, uint256 amount) external; function getVestingSchedule() external view returns (Vesting memory); function createBurningRound( address nft, uint256 startTime, uint256 endTime, uint256 totalToBurn, uint256 minBurnPerTx, uint256 maxBurnPerTx ) external; function stopBurningRound() external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.18; import {IERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; interface IERC20Burnable is IERC20 { function burn(uint256 amount) external; function burnFrom(address account, uint256 amount) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.18; interface IERC721Mint { function mint(address to, uint256 amount) external returns (uint256 tokenId); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20Upgradeable { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 amount) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20MetadataUpgradeable is IERC20Upgradeable { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
{ "remappings": [ "@erc1363/=lib/erc1363-payable-token/", "@openzeppelin/=lib/openzeppelin-contracts/", "@oz-upgradeable/=lib/openzeppelin-contracts-upgradeable/", "ds-test/=lib/forge-std/lib/ds-test/src/", "erc1363-payable-token/=lib/erc1363-payable-token/", "erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/", "forge-std/=lib/forge-std/src/", "murky/=lib/murky/src/", "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/", "openzeppelin-contracts/=lib/openzeppelin-contracts/", "openzeppelin/=lib/openzeppelin-contracts-upgradeable/contracts/" ], "optimizer": { "enabled": true, "runs": 10000 }, "metadata": { "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "london", "libraries": {} }
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"BurningRoundIsOverOrNotStarted","type":"error"},{"inputs":[],"name":"BurningRoundMustBeActive","type":"error"},{"inputs":[],"name":"CliffBeforeStartTime","type":"error"},{"inputs":[],"name":"CliffNotEnded","type":"error"},{"inputs":[],"name":"IncorrectBurningRoundLimits","type":"error"},{"inputs":[],"name":"IncorrectBurningRoundTime","type":"error"},{"inputs":[],"name":"IncorrectSchedulePortions","type":"error"},{"inputs":[{"internalType":"uint256","name":"incorrectTime","type":"uint256"}],"name":"IncorrectScheduleTime","type":"error"},{"inputs":[],"name":"LessThanMinLimit","type":"error"},{"inputs":[],"name":"MintingAfterCliffIsForbidden","type":"error"},{"inputs":[],"name":"MoreThenMaxLimit","type":"error"},{"inputs":[],"name":"NotEnoughTokensToClaim","type":"error"},{"inputs":[],"name":"OnlyMinter","type":"error"},{"inputs":[],"name":"OnlyVestingManager","type":"error"},{"inputs":[],"name":"StartTimeAlreadyElapsed","type":"error"},{"inputs":[],"name":"TransfersNotAllowed","type":"error"},{"inputs":[],"name":"VestingNotStarted","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"inputs":[],"name":"ZeroParam","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"components":[{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256","name":"totalToBurn","type":"uint256"},{"internalType":"uint256","name":"minBurnPerTx","type":"uint256"},{"internalType":"uint256","name":"maxBurnPerTx","type":"uint256"},{"internalType":"uint256","name":"totalBurned","type":"uint256"}],"indexed":false,"internalType":"struct VestingToken.BurningRound","name":"","type":"tuple"}],"name":"BurningRoundCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"buyer","type":"address"},{"indexed":true,"internalType":"address","name":"vestingToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"components":[{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"cliff","type":"uint256"},{"components":[{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256","name":"portion","type":"uint256"}],"internalType":"struct Schedule[]","name":"schedule","type":"tuple[]"}],"indexed":false,"internalType":"struct Vesting","name":"vestingSchedule","type":"tuple"}],"name":"Locked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"nft","type":"address"}],"name":"NftAddressSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"holder","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountOfTokens","type":"uint256"}],"name":"NftMinted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Released","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"components":[{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"cliff","type":"uint256"},{"components":[{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256","name":"portion","type":"uint256"}],"internalType":"struct Schedule[]","name":"schedule","type":"tuple[]"}],"indexed":false,"internalType":"struct Vesting","name":"vesting","type":"tuple"}],"name":"VestingScheduleSet","type":"event"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"availableBalanceOf","outputs":[{"internalType":"uint256","name":"releasable","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"claimNft","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256","name":"totalToBurn","type":"uint256"},{"internalType":"uint256","name":"minBurnPerTx","type":"uint256"},{"internalType":"uint256","name":"maxBurnPerTx","type":"uint256"}],"name":"createBurningRound","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getBaseToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBurningRoundParams","outputs":[{"components":[{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256","name":"totalToBurn","type":"uint256"},{"internalType":"uint256","name":"minBurnPerTx","type":"uint256"},{"internalType":"uint256","name":"maxBurnPerTx","type":"uint256"},{"internalType":"uint256","name":"totalBurned","type":"uint256"}],"internalType":"struct VestingToken.BurningRound","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getInitialLockedSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMinter","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getVestingSchedule","outputs":[{"components":[{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"cliff","type":"uint256"},{"components":[{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256","name":"portion","type":"uint256"}],"internalType":"struct Schedule[]","name":"schedule","type":"tuple[]"}],"internalType":"struct Vesting","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"address","name":"minter","type":"address"},{"internalType":"address","name":"baseToken","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lockedSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"cliff","type":"uint256"},{"components":[{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256","name":"portion","type":"uint256"}],"internalType":"struct Schedule[]","name":"schedule","type":"tuple[]"}],"name":"setVestingSchedule","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stopBurningRound","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unlockedSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.