Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 25 from a total of 6,953 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Withdraw Epochs | 19825902 | 229 days ago | IN | 0 ETH | 0.0012556 | ||||
Withdraw Epochs | 16769578 | 658 days ago | IN | 0 ETH | 0.00311535 | ||||
Withdraw Epochs | 15669704 | 812 days ago | IN | 0 ETH | 0.00275262 | ||||
Withdraw Epochs | 15667891 | 812 days ago | IN | 0 ETH | 0.00187381 | ||||
Withdraw Epochs | 15667880 | 812 days ago | IN | 0 ETH | 0.00215245 | ||||
Withdraw Epochs | 15477160 | 840 days ago | IN | 0 ETH | 0.00084677 | ||||
Withdraw Epochs | 15393594 | 854 days ago | IN | 0 ETH | 0.00295578 | ||||
Withdraw Epochs | 15360768 | 859 days ago | IN | 0 ETH | 0.00167969 | ||||
Withdraw Epochs | 15303570 | 868 days ago | IN | 0 ETH | 0.00547741 | ||||
Withdraw Epochs | 15215315 | 882 days ago | IN | 0 ETH | 0.00440231 | ||||
Withdraw Epochs | 15073913 | 903 days ago | IN | 0 ETH | 0.00282168 | ||||
Withdraw Epochs | 14973419 | 921 days ago | IN | 0 ETH | 0.00464788 | ||||
Withdraw Epochs | 14961376 | 923 days ago | IN | 0 ETH | 0.00400313 | ||||
Withdraw Epochs | 14960932 | 923 days ago | IN | 0 ETH | 0.00556593 | ||||
Withdraw Epochs | 14960924 | 923 days ago | IN | 0 ETH | 0.00466471 | ||||
Withdraw Epochs | 14960652 | 923 days ago | IN | 0 ETH | 0.00554053 | ||||
Withdraw Epochs | 14951914 | 925 days ago | IN | 0 ETH | 0.00364232 | ||||
Withdraw Epochs | 14951908 | 925 days ago | IN | 0 ETH | 0.00331265 | ||||
Withdraw Epochs | 14951199 | 925 days ago | IN | 0 ETH | 0.01023455 | ||||
Withdraw Epochs | 14939275 | 927 days ago | IN | 0 ETH | 0.00475351 | ||||
Withdraw Epochs | 14932077 | 928 days ago | IN | 0 ETH | 0.00464236 | ||||
Withdraw Epochs | 14931897 | 928 days ago | IN | 0 ETH | 0.00522939 | ||||
Withdraw Epochs | 14930977 | 928 days ago | IN | 0 ETH | 0.00697286 | ||||
Withdraw Epochs | 14920592 | 930 days ago | IN | 0 ETH | 0.00505707 | ||||
Withdraw Epochs | 14920023 | 930 days ago | IN | 0 ETH | 0.00286737 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Name:
AcceleratedExitQueue
Compiler Version
v0.8.4+commit.c7e474f2
Optimization Enabled:
Yes with 999999 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
pragma solidity ^0.8.4; // SPDX-License-Identifier: GPL-3.0-or-later import "@openzeppelin/contracts/access/Ownable.sol"; import "./TempleERC20Token.sol"; import "./ExitQueue.sol"; import "./TempleStaking.sol"; // import "hardhat/console.sol"; /** * An accelerated exit queue so we can speed up price discovery while maintaining * exit queue ordering */ contract AcceleratedExitQueue is Ownable, IExitQueue { ExitQueue public exitQueue; TempleStaking public staking; IERC20 public templeToken; // factor at which we will accelerate the current epoch uint256 public epochAccelerationFactorNumerator = 5; // factor at which we will accelerate the current epoch uint256 public epochAccelerationFactorDenominator = 4; // When do we begin acceleration. Default high number // implies it's disabled at launch uint256 public accelerationStartAtEpoch = 5000; constructor(IERC20 _templeToken, ExitQueue _exitQueue, TempleStaking _staking) { templeToken = _templeToken; exitQueue = _exitQueue; staking = _staking; } function currentEpoch() public view returns (uint256) { uint currentUnacceleratedEpoch = exitQueue.currentEpoch(); if (currentUnacceleratedEpoch < accelerationStartAtEpoch) { return currentUnacceleratedEpoch; } return currentUnacceleratedEpoch + ((currentUnacceleratedEpoch - accelerationStartAtEpoch) * epochAccelerationFactorNumerator / epochAccelerationFactorDenominator); } function setMaxPerEpoch(uint256 _maxPerEpoch) external onlyOwner { exitQueue.setMaxPerEpoch(_maxPerEpoch); } function setMaxPerAddress(uint256 _maxPerAddress) external onlyOwner { exitQueue.setMaxPerAddress(_maxPerAddress); } function setEpochSize(uint256 _epochSize) external onlyOwner { exitQueue.setEpochSize(_epochSize); } function setAccelerationPolicy(uint256 numerator, uint256 denominator, uint256 startAtEpoch) external onlyOwner { epochAccelerationFactorNumerator = numerator; epochAccelerationFactorDenominator = denominator; accelerationStartAtEpoch = startAtEpoch; } // leaving this out. Legacy when staking was also by block and we wanted epochs to line up //function setStartingBlock(uint256 _firstBlock) external onlyOwner; function setOwedTemple(address[] memory _users, uint256[] memory _amounts) external onlyOwner { exitQueue.setOwedTemple(_users, _amounts); } function migrateTempleFromEpochs(uint256[] memory epochs, uint256 length, uint256 expectedAmountTemple) internal { uint256 templeBalancePreMigrate = templeToken.balanceOf(address(this)); exitQueue.migrate(msg.sender, epochs, length, this); require((templeToken.balanceOf(address(this)) - templeBalancePreMigrate) == expectedAmountTemple, "Balance increase should be equal to a user's bag for a given exit queue epoch"); } /** * Restake the given epochs */ function restake(uint256[] calldata epochs, uint256 length) external { uint256 allocation; for (uint256 i=0; i<length; i++) { allocation += exitQueue.currentEpochAllocation(msg.sender, epochs[i]); } migrateTempleFromEpochs(epochs, length, allocation); SafeERC20.safeIncreaseAllowance(templeToken, address(staking), allocation); staking.stakeFor(msg.sender, allocation); } /** * Withdraw processed epochs, at an accelerated rate */ function withdrawEpochs(uint256[] memory epochs, uint256 length) external { uint256 totalAmount; uint256 maxExitableEpoch = currentEpoch(); for (uint i = 0; i < length; i++) { require(epochs[i] < maxExitableEpoch, "Can only withdraw from processed epochs"); totalAmount += exitQueue.currentEpochAllocation(msg.sender, epochs[i]); } migrateTempleFromEpochs(epochs, length, totalAmount); SafeERC20.safeTransfer(templeToken, msg.sender, totalAmount); } /** * Required so we can allow all active exit queue buys to be listed, and 'insta exited' * when bought. * * Stores any temple sent to it _temporarily_ via 'marketBuy', with the expectation it will be * transferred to the buyer. */ function join(address _exiter, uint256 _amount) override external { require(msg.sender == address(exitQueue), "only exit queue"); { _exiter; } SafeERC20.safeTransferFrom(templeToken, msg.sender, address(this), _amount); } /** * Disable's by resetting the exit queue owner to the owner of this contract */ function disableAcceleratedExitQueue() external onlyOwner { exitQueue.transferOwnership(owner()); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
pragma solidity ^0.8.4; // SPDX-License-Identifier: GPL-3.0-or-later import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; contract TempleERC20Token is ERC20, ERC20Burnable, Ownable, AccessControl { bytes32 public constant CAN_MINT = keccak256("CAN_MINT"); constructor() ERC20("Temple", "TEMPLE") { _setupRole(DEFAULT_ADMIN_ROLE, owner()); } function mint(address to, uint256 amount) external { require(hasRole(CAN_MINT, msg.sender), "Caller cannot mint"); _mint(to, amount); } function addMinter(address account) external onlyOwner { grantRole(CAN_MINT, account); } function removeMinter(address account) external onlyOwner { revokeRole(CAN_MINT, account); } }
pragma solidity ^0.8.4; // SPDX-License-Identifier: GPL-3.0-or-later import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "./TempleERC20Token.sol"; // import "hardhat/console.sol"; // Assumption, any new unstake queue will have the same interface interface IExitQueue { function join(address _exiter, uint256 _amount) external; } /** * How all exit of TEMPLE rewards are managed. */ contract ExitQueue is Ownable { struct User { // Total currently in queue uint256 Amount; // First epoch for which the user is in the unstake queue uint256 FirstExitEpoch; // Last epoch for which the user has a pending unstake uint256 LastExitEpoch; // All epochs where the user has an exit allocation mapping(uint256 => uint256) Exits; } // total queued to be exited in a given epoch mapping(uint256 => uint256) public totalPerEpoch; // temple owed by users from buying above $30k mapping(address => uint256) public owedTemple; // The first unwithdrawn epoch for the user mapping(address => User) public userData; TempleERC20Token immutable public TEMPLE; // The token being staked, for which TEMPLE rewards are generated // Limit of how much temple can exit per epoch uint256 public maxPerEpoch; // Limit of how much temple can exit per address per epoch uint256 public maxPerAddress; // epoch size, in blocks uint256 public epochSize; // the block we use to work out what epoch we are in uint256 public firstBlock; // The next free block on which a user can commence their unstake uint256 public nextUnallocatedEpoch; event JoinQueue(address exiter, uint256 amount); event Withdrawal(address exiter, uint256 amount); constructor( TempleERC20Token _TEMPLE, uint256 _maxPerEpoch, uint256 _maxPerAddress, uint256 _epochSize) { TEMPLE = _TEMPLE; maxPerEpoch = _maxPerEpoch; maxPerAddress = _maxPerAddress; epochSize = _epochSize; firstBlock = block.number; nextUnallocatedEpoch = 0; } function setMaxPerEpoch(uint256 _maxPerEpoch) external onlyOwner { maxPerEpoch = _maxPerEpoch; } function setMaxPerAddress(uint256 _maxPerAddress) external onlyOwner { maxPerAddress = _maxPerAddress; } function setEpochSize(uint256 _epochSize) external onlyOwner { epochSize = _epochSize; } function setStartingBlock(uint256 _firstBlock) external onlyOwner { require(_firstBlock < firstBlock, "Can only move start block back, not forward"); firstBlock = _firstBlock; } function setOwedTemple(address[] memory _users, uint256[] memory _amounts) external onlyOwner { uint256 size = _users.length; require(_amounts.length == size, "not of equal sizes"); for (uint256 i=0; i<size; i++) { owedTemple[_users[i]] = _amounts[i]; } } function currentEpoch() public view returns (uint256) { return (block.number - firstBlock) / epochSize; } function currentEpochAllocation(address _exiter, uint256 _epoch) external view returns (uint256) { return userData[_exiter].Exits[_epoch]; } function join(address _exiter, uint256 _amount) external { require(_amount > 0, "Amount must be > 0"); uint256 owedAmount = owedTemple[_exiter]; require(_amount > owedAmount, "owing more than withdraw amount"); // burn owed temple and update amount if (owedAmount > 0) { TEMPLE.burnFrom(msg.sender, owedAmount); _amount = _amount - owedAmount; owedTemple[_exiter] = 0; } if (nextUnallocatedEpoch < currentEpoch()) { nextUnallocatedEpoch = currentEpoch() + 1; } User storage user = userData[_exiter]; uint256 unallocatedAmount = _amount; uint256 _nextUnallocatedEpoch = nextUnallocatedEpoch; uint256 nextAvailableEpochForUser = _nextUnallocatedEpoch; if (user.LastExitEpoch > nextAvailableEpochForUser) { nextAvailableEpochForUser = user.LastExitEpoch; } while (unallocatedAmount > 0) { // work out allocation for the next available epoch uint256 allocationForEpoch = unallocatedAmount; if (user.Exits[nextAvailableEpochForUser] + allocationForEpoch > maxPerAddress) { allocationForEpoch = maxPerAddress - user.Exits[nextAvailableEpochForUser]; } if (totalPerEpoch[nextAvailableEpochForUser] + allocationForEpoch > maxPerEpoch) { allocationForEpoch = maxPerEpoch - totalPerEpoch[nextAvailableEpochForUser]; } // Bookkeeping if (allocationForEpoch > 0) { if (user.Amount == 0) { user.FirstExitEpoch = nextAvailableEpochForUser; } user.Amount += allocationForEpoch; user.Exits[nextAvailableEpochForUser] += allocationForEpoch; totalPerEpoch[nextAvailableEpochForUser] += allocationForEpoch; user.LastExitEpoch = nextAvailableEpochForUser; if (totalPerEpoch[nextAvailableEpochForUser] >= maxPerEpoch) { _nextUnallocatedEpoch = nextAvailableEpochForUser; } unallocatedAmount -= allocationForEpoch; } nextAvailableEpochForUser += 1; } // update outside of main loop, so we spend gas once nextUnallocatedEpoch = _nextUnallocatedEpoch; SafeERC20.safeTransferFrom(TEMPLE, msg.sender, address(this), _amount); emit JoinQueue(_exiter, _amount); } /** * Withdraw internal per epoch */ function withdrawInternal(uint256 epoch, address sender, bool isMigration) internal returns (uint256 amount) { require(epoch < currentEpoch() || isMigration, "Can only withdraw from past epochs"); User storage user = userData[sender]; amount = user.Exits[epoch]; delete user.Exits[epoch]; totalPerEpoch[epoch] -= amount; user.Amount -= amount; if (user.Amount == 0) { delete userData[sender]; } } /** * Withdraw processed allowance from multiple epochs */ function withdrawEpochs(uint256[] calldata epochs, uint256 length) external { uint256 totalAmount; for (uint i = 0; i < length; i++) { if (userData[msg.sender].Amount > 0) { uint256 amount = withdrawInternal(epochs[i], msg.sender, false); totalAmount += amount; } } SafeERC20.safeTransfer(TEMPLE, msg.sender, totalAmount); emit Withdrawal(msg.sender, totalAmount); } /** * Owner only, migrate users between exit queue implementations */ function migrate(address exiter, uint256[] calldata epochs, uint256 length, IExitQueue newExitQueue) external onlyOwner { uint256 totalAmount; for (uint i = 0; i < length; i++) { if (userData[exiter].Amount > 0) { uint256 amount = withdrawInternal(epochs[i], exiter, true); totalAmount += amount; } } SafeERC20.safeIncreaseAllowance(TEMPLE, address(newExitQueue), totalAmount); newExitQueue.join(exiter, totalAmount); } }
pragma solidity ^0.8.4; // SPDX-License-Identifier: GPL-3.0-or-later import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "./ABDKMath64x64.sol"; import "./TempleERC20Token.sol"; import "./OGTemple.sol"; import "./ExitQueue.sol"; // import "hardhat/console.sol"; /** * Mechancics of how a user can stake temple. */ contract TempleStaking is Ownable { using ABDKMath64x64 for int128; TempleERC20Token immutable public TEMPLE; // The token being staked, for which TEMPLE rewards are generated OGTemple immutable public OG_TEMPLE; // Token used to redeem staked TEMPLE ExitQueue public EXIT_QUEUE; // unstake exit queue // epoch percentage yield, as an ABDKMath64x64 int128 public epy; // epoch size, in seconds uint256 public epochSizeSeconds; // The starting timestamp. from where staking starts uint256 public startTimestamp; // epy compounded over every epoch since the contract creation up // until lastUpdatedEpoch. Represented as an ABDKMath64x64 int128 public accumulationFactor; // the epoch up to which we have calculated accumulationFactor. uint256 public lastUpdatedEpoch; event StakeCompleted(address _staker, uint256 _amount, uint256 _lockedUntil); event AccumulationFactorUpdated(uint256 _epochsProcessed, uint256 _currentEpoch, uint256 _accumulationFactor); event UnstakeCompleted(address _staker, uint256 _amount); constructor( TempleERC20Token _TEMPLE, ExitQueue _EXIT_QUEUE, uint256 _epochSizeSeconds, uint256 _startTimestamp) { require(_startTimestamp < block.timestamp, "Start timestamp must be in the past"); require(_startTimestamp > (block.timestamp - (24 * 2 * 60 * 60)), "Start timestamp can't be more than 2 days in the past"); TEMPLE = _TEMPLE; EXIT_QUEUE = _EXIT_QUEUE; // Each version of the staking contract needs it's own instance of OGTemple users can use to // claim back rewards OG_TEMPLE = new OGTemple(); epochSizeSeconds = _epochSizeSeconds; startTimestamp = _startTimestamp; epy = ABDKMath64x64.fromUInt(1); accumulationFactor = ABDKMath64x64.fromUInt(1); } /** Sets epoch percentage yield */ function setExitQueue(ExitQueue _EXIT_QUEUE) external onlyOwner { EXIT_QUEUE = _EXIT_QUEUE; } /** Sets epoch percentage yield */ function setEpy(uint256 _numerator, uint256 _denominator) external onlyOwner { _updateAccumulationFactor(); epy = ABDKMath64x64.fromUInt(1).add(ABDKMath64x64.divu(_numerator, _denominator)); } /** Get EPY as uint, scaled up the given factor (for reporting) */ function getEpy(uint256 _scale) external view returns (uint256) { return epy.sub(ABDKMath64x64.fromUInt(1)).mul(ABDKMath64x64.fromUInt(_scale)).toUInt(); } function currentEpoch() public view returns (uint256) { return (block.timestamp - startTimestamp) / epochSizeSeconds; } /** Return current accumulation factor, scaled up to account for fractional component */ function getAccumulationFactor(uint256 _scale) external view returns(uint256) { return _accumulationFactorAt(currentEpoch()).mul(ABDKMath64x64.fromUInt(_scale)).toUInt(); } /** Calculate the updated accumulation factor, based on the current epoch */ function _accumulationFactorAt(uint256 epoch) private view returns(int128) { uint256 _nUnupdatedEpochs = epoch - lastUpdatedEpoch; return accumulationFactor.mul(epy.pow(_nUnupdatedEpochs)); } /** Balance in TEMPLE for a given amount of OG_TEMPLE */ function balance(uint256 amountOgTemple) public view returns(uint256) { return _overflowSafeMul1e18( ABDKMath64x64.divu(amountOgTemple, 1e18).mul(_accumulationFactorAt(currentEpoch())) ); } /** updates rewards in pool */ function _updateAccumulationFactor() internal { uint256 _currentEpoch = currentEpoch(); // still in previous epoch, no action. // NOTE: should be a pre-condition that _currentEpoch >= lastUpdatedEpoch // It's possible to end up in this state if we shorten epoch size. // As such, it's not baked as a precondition if (_currentEpoch <= lastUpdatedEpoch) { return; } accumulationFactor = _accumulationFactorAt(_currentEpoch); lastUpdatedEpoch = _currentEpoch; uint256 _nUnupdatedEpochs = _currentEpoch - lastUpdatedEpoch; emit AccumulationFactorUpdated(_nUnupdatedEpochs, _currentEpoch, accumulationFactor.mul(10000).toUInt()); } /** Stake on behalf of a given address. Used by other contracts (like Presale) */ function stakeFor(address _staker, uint256 _amountTemple) public returns(uint256 amountOgTemple) { require(_amountTemple > 0, "Cannot stake 0 tokens"); _updateAccumulationFactor(); // net past value/genesis value/OG Value for the temple you are putting in. amountOgTemple = _overflowSafeMul1e18(ABDKMath64x64.divu(_amountTemple, 1e18).div(accumulationFactor)); SafeERC20.safeTransferFrom(TEMPLE, msg.sender, address(this), _amountTemple); OG_TEMPLE.mint(_staker, amountOgTemple); emit StakeCompleted(_staker, _amountTemple, 0); return amountOgTemple; } /** Stake temple */ function stake(uint256 _amountTemple) external returns(uint256 amountOgTemple) { return stakeFor(msg.sender, _amountTemple); } /** Unstake temple */ function unstake(uint256 _amountOgTemple) external { require(OG_TEMPLE.allowance(msg.sender, address(this)) >= _amountOgTemple, 'Insufficient OGTemple allowance. Cannot unstake'); _updateAccumulationFactor(); uint256 unstakeBalanceTemple = balance(_amountOgTemple); OG_TEMPLE.burnFrom(msg.sender, _amountOgTemple); SafeERC20.safeIncreaseAllowance(TEMPLE, address(EXIT_QUEUE), unstakeBalanceTemple); EXIT_QUEUE.join(msg.sender, unstakeBalanceTemple); emit UnstakeCompleted(msg.sender, _amountOgTemple); } function _overflowSafeMul1e18(int128 amountFixedPoint) internal pure returns (uint256) { uint256 integralDigits = amountFixedPoint.toUInt(); uint256 fractionalDigits = amountFixedPoint.sub(ABDKMath64x64.fromUInt(integralDigits)).mul(ABDKMath64x64.fromUInt(1e18)).toUInt(); return (integralDigits * 1e18) + fractionalDigits; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @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 Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.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.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * 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 ERC20 is Context, IERC20, IERC20Metadata { 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}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _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 value {ERC20} uses, unless this function is * 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: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, 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}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), 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}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - 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) { _approve(_msgSender(), spender, _allowances[_msgSender()][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) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * 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: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, 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; _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; } _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 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 {} }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @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 `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../ERC20.sol"; import "../../../utils/Context.sol"; /** * @dev Extension of {ERC20} that allows token holders to destroy both their own * tokens and those that they have an allowance for, in a way that can be * recognized off-chain (via event analysis). */ abstract contract ERC20Burnable is Context, ERC20 { /** * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public virtual { _burn(_msgSender(), amount); } /** * @dev Destroys `amount` tokens from `account`, deducting from the caller's * allowance. * * See {ERC20-_burn} and {ERC20-allowance}. * * Requirements: * * - the caller must have allowance for ``accounts``'s tokens of at least * `amount`. */ function burnFrom(address account, uint256 amount) public virtual { uint256 currentAllowance = allowance(account, _msgSender()); require(currentAllowance >= amount, "ERC20: burn amount exceeds allowance"); unchecked { _approve(account, _msgSender(), currentAllowance - amount); } _burn(account, amount); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor() { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IAccessControl.sol"; import "../utils/Context.sol"; import "../utils/Strings.sol"; import "../utils/introspection/ERC165.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role, _msgSender()); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } function _grantRole(bytes32 role, address account) private { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @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 pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20.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)); } } /** * @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 pragma solidity ^0.8.0; /** * @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 * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 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 functionCall(target, data, "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"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(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) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(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) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason 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 { // 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 assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: BSD-4-Clause /* * ABDK Math 64.64 Smart Contract Library. Copyright © 2019 by ABDK Consulting. * Author: Mikhail Vladimirov <[email protected]> */ pragma solidity ^0.8.4; /** * Smart contract library of mathematical functions operating with signed * 64.64-bit fixed point numbers. Signed 64.64-bit fixed point number is * basically a simple fraction whose numerator is signed 128-bit integer and * denominator is 2^64. As long as denominator is always the same, there is no * need to store it, thus in Solidity signed 64.64-bit fixed point numbers are * represented by int128 type holding only the numerator. */ library ABDKMath64x64 { /* * Minimum value signed 64.64-bit fixed point number may have. */ int128 private constant MIN_64x64 = -0x80000000000000000000000000000000; /* * Maximum value signed 64.64-bit fixed point number may have. */ int128 private constant MAX_64x64 = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; /** * Convert signed 256-bit integer number into signed 64.64-bit fixed point * number. Revert on overflow. * * @param x signed 256-bit integer number * @return signed 64.64-bit fixed point number */ function fromInt (int256 x) internal pure returns (int128) { unchecked { require (x >= -0x8000000000000000 && x <= 0x7FFFFFFFFFFFFFFF); return int128 (x << 64); } } /** * Convert signed 64.64 fixed point number into signed 64-bit integer number * rounding down. * * @param x signed 64.64-bit fixed point number * @return signed 64-bit integer number */ function toInt (int128 x) internal pure returns (int64) { unchecked { return int64 (x >> 64); } } /** * Convert unsigned 256-bit integer number into signed 64.64-bit fixed point * number. Revert on overflow. * * @param x unsigned 256-bit integer number * @return signed 64.64-bit fixed point number */ function fromUInt (uint256 x) internal pure returns (int128) { unchecked { require (x <= 0x7FFFFFFFFFFFFFFF); return int128 (int256 (x << 64)); } } /** * Convert signed 64.64 fixed point number into unsigned 64-bit integer * number rounding down. Revert on underflow. * * @param x signed 64.64-bit fixed point number * @return unsigned 64-bit integer number */ function toUInt (int128 x) internal pure returns (uint64) { unchecked { require (x >= 0); return uint64 (uint128 (x >> 64)); } } /** * Convert signed 128.128 fixed point number into signed 64.64-bit fixed point * number rounding down. Revert on overflow. * * @param x signed 128.128-bin fixed point number * @return signed 64.64-bit fixed point number */ function from128x128 (int256 x) internal pure returns (int128) { unchecked { int256 result = x >> 64; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } } /** * Convert signed 64.64 fixed point number into signed 128.128 fixed point * number. * * @param x signed 64.64-bit fixed point number * @return signed 128.128 fixed point number */ function to128x128 (int128 x) internal pure returns (int256) { unchecked { return int256 (x) << 64; } } /** * Calculate x + y. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function add (int128 x, int128 y) internal pure returns (int128) { unchecked { int256 result = int256(x) + y; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } } /** * Calculate x - y. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function sub (int128 x, int128 y) internal pure returns (int128) { unchecked { int256 result = int256(x) - y; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } } /** * Calculate x * y rounding down. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function mul (int128 x, int128 y) internal pure returns (int128) { unchecked { int256 result = int256(x) * y >> 64; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } } /** * Calculate x * y rounding towards zero, where x is signed 64.64 fixed point * number and y is signed 256-bit integer number. Revert on overflow. * * @param x signed 64.64 fixed point number * @param y signed 256-bit integer number * @return signed 256-bit integer number */ function muli (int128 x, int256 y) internal pure returns (int256) { unchecked { if (x == MIN_64x64) { require (y >= -0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF && y <= 0x1000000000000000000000000000000000000000000000000); return -y << 63; } else { bool negativeResult = false; if (x < 0) { x = -x; negativeResult = true; } if (y < 0) { y = -y; // We rely on overflow behavior here negativeResult = !negativeResult; } uint256 absoluteResult = mulu (x, uint256 (y)); if (negativeResult) { require (absoluteResult <= 0x8000000000000000000000000000000000000000000000000000000000000000); return -int256 (absoluteResult); // We rely on overflow behavior here } else { require (absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); return int256 (absoluteResult); } } } } /** * Calculate x * y rounding down, where x is signed 64.64 fixed point number * and y is unsigned 256-bit integer number. Revert on overflow. * * @param x signed 64.64 fixed point number * @param y unsigned 256-bit integer number * @return unsigned 256-bit integer number */ function mulu (int128 x, uint256 y) internal pure returns (uint256) { unchecked { if (y == 0) return 0; require (x >= 0); uint256 lo = (uint256 (int256 (x)) * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) >> 64; uint256 hi = uint256 (int256 (x)) * (y >> 128); require (hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); hi <<= 64; require (hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - lo); return hi + lo; } } /** * Calculate x / y rounding towards zero. Revert on overflow or when y is * zero. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function div (int128 x, int128 y) internal pure returns (int128) { unchecked { require (y != 0); int256 result = (int256 (x) << 64) / y; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } } /** * Calculate x / y rounding towards zero, where x and y are signed 256-bit * integer numbers. Revert on overflow or when y is zero. * * @param x signed 256-bit integer number * @param y signed 256-bit integer number * @return signed 64.64-bit fixed point number */ function divi (int256 x, int256 y) internal pure returns (int128) { unchecked { require (y != 0); bool negativeResult = false; if (x < 0) { x = -x; // We rely on overflow behavior here negativeResult = true; } if (y < 0) { y = -y; // We rely on overflow behavior here negativeResult = !negativeResult; } uint128 absoluteResult = divuu (uint256 (x), uint256 (y)); if (negativeResult) { require (absoluteResult <= 0x80000000000000000000000000000000); return -int128 (absoluteResult); // We rely on overflow behavior here } else { require (absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); return int128 (absoluteResult); // We rely on overflow behavior here } } } /** * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit * integer numbers. Revert on overflow or when y is zero. * * @param x unsigned 256-bit integer number * @param y unsigned 256-bit integer number * @return signed 64.64-bit fixed point number */ function divu (uint256 x, uint256 y) internal pure returns (int128) { unchecked { require (y != 0); uint128 result = divuu (x, y); require (result <= uint128 (MAX_64x64)); return int128 (result); } } /** * Calculate -x. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function neg (int128 x) internal pure returns (int128) { unchecked { require (x != MIN_64x64); return -x; } } /** * Calculate |x|. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function abs (int128 x) internal pure returns (int128) { unchecked { require (x != MIN_64x64); return x < 0 ? -x : x; } } /** * Calculate 1 / x rounding towards zero. Revert on overflow or when x is * zero. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function inv (int128 x) internal pure returns (int128) { unchecked { require (x != 0); int256 result = int256 (0x100000000000000000000000000000000) / x; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } } /** * Calculate arithmetics average of x and y, i.e. (x + y) / 2 rounding down. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function avg (int128 x, int128 y) internal pure returns (int128) { unchecked { return int128 ((int256 (x) + int256 (y)) >> 1); } } /** * Calculate geometric average of x and y, i.e. sqrt (x * y) rounding down. * Revert on overflow or in case x * y is negative. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function gavg (int128 x, int128 y) internal pure returns (int128) { unchecked { int256 m = int256 (x) * int256 (y); require (m >= 0); require (m < 0x4000000000000000000000000000000000000000000000000000000000000000); return int128 (sqrtu (uint256 (m))); } } /** * Calculate x^y assuming 0^0 is 1, where x is signed 64.64 fixed point number * and y is unsigned 256-bit integer number. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @param y uint256 value * @return signed 64.64-bit fixed point number */ function pow (int128 x, uint256 y) internal pure returns (int128) { unchecked { bool negative = x < 0 && y & 1 == 1; uint256 absX = uint128 (x < 0 ? -x : x); uint256 absResult; absResult = 0x100000000000000000000000000000000; if (absX <= 0x10000000000000000) { absX <<= 63; while (y != 0) { if (y & 0x1 != 0) { absResult = absResult * absX >> 127; } absX = absX * absX >> 127; if (y & 0x2 != 0) { absResult = absResult * absX >> 127; } absX = absX * absX >> 127; if (y & 0x4 != 0) { absResult = absResult * absX >> 127; } absX = absX * absX >> 127; if (y & 0x8 != 0) { absResult = absResult * absX >> 127; } absX = absX * absX >> 127; y >>= 4; } absResult >>= 64; } else { uint256 absXShift = 63; if (absX < 0x1000000000000000000000000) { absX <<= 32; absXShift -= 32; } if (absX < 0x10000000000000000000000000000) { absX <<= 16; absXShift -= 16; } if (absX < 0x1000000000000000000000000000000) { absX <<= 8; absXShift -= 8; } if (absX < 0x10000000000000000000000000000000) { absX <<= 4; absXShift -= 4; } if (absX < 0x40000000000000000000000000000000) { absX <<= 2; absXShift -= 2; } if (absX < 0x80000000000000000000000000000000) { absX <<= 1; absXShift -= 1; } uint256 resultShift = 0; while (y != 0) { require (absXShift < 64); if (y & 0x1 != 0) { absResult = absResult * absX >> 127; resultShift += absXShift; if (absResult > 0x100000000000000000000000000000000) { absResult >>= 1; resultShift += 1; } } absX = absX * absX >> 127; absXShift <<= 1; if (absX >= 0x100000000000000000000000000000000) { absX >>= 1; absXShift += 1; } y >>= 1; } require (resultShift < 64); absResult >>= 64 - resultShift; } int256 result = negative ? -int256 (absResult) : int256 (absResult); require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } } /** * Calculate sqrt (x) rounding down. Revert if x < 0. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function sqrt (int128 x) internal pure returns (int128) { unchecked { require (x >= 0); return int128 (sqrtu (uint256 (int256 (x)) << 64)); } } /** * Calculate binary logarithm of x. Revert if x <= 0. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function log_2 (int128 x) internal pure returns (int128) { unchecked { require (x > 0); int256 msb = 0; int256 xc = x; if (xc >= 0x10000000000000000) { xc >>= 64; msb += 64; } if (xc >= 0x100000000) { xc >>= 32; msb += 32; } if (xc >= 0x10000) { xc >>= 16; msb += 16; } if (xc >= 0x100) { xc >>= 8; msb += 8; } if (xc >= 0x10) { xc >>= 4; msb += 4; } if (xc >= 0x4) { xc >>= 2; msb += 2; } if (xc >= 0x2) msb += 1; // No need to shift xc anymore int256 result = msb - 64 << 64; uint256 ux = uint256 (int256 (x)) << uint256 (127 - msb); for (int256 bit = 0x8000000000000000; bit > 0; bit >>= 1) { ux *= ux; uint256 b = ux >> 255; ux >>= 127 + b; result += bit * int256 (b); } return int128 (result); } } /** * Calculate natural logarithm of x. Revert if x <= 0. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function ln (int128 x) internal pure returns (int128) { unchecked { require (x > 0); return int128 (int256 ( uint256 (int256 (log_2 (x))) * 0xB17217F7D1CF79ABC9E3B39803F2F6AF >> 128)); } } /** * Calculate binary exponent of x. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function exp_2 (int128 x) internal pure returns (int128) { unchecked { require (x < 0x400000000000000000); // Overflow if (x < -0x400000000000000000) return 0; // Underflow uint256 result = 0x80000000000000000000000000000000; if (x & 0x8000000000000000 > 0) result = result * 0x16A09E667F3BCC908B2FB1366EA957D3E >> 128; if (x & 0x4000000000000000 > 0) result = result * 0x1306FE0A31B7152DE8D5A46305C85EDEC >> 128; if (x & 0x2000000000000000 > 0) result = result * 0x1172B83C7D517ADCDF7C8C50EB14A791F >> 128; if (x & 0x1000000000000000 > 0) result = result * 0x10B5586CF9890F6298B92B71842A98363 >> 128; if (x & 0x800000000000000 > 0) result = result * 0x1059B0D31585743AE7C548EB68CA417FD >> 128; if (x & 0x400000000000000 > 0) result = result * 0x102C9A3E778060EE6F7CACA4F7A29BDE8 >> 128; if (x & 0x200000000000000 > 0) result = result * 0x10163DA9FB33356D84A66AE336DCDFA3F >> 128; if (x & 0x100000000000000 > 0) result = result * 0x100B1AFA5ABCBED6129AB13EC11DC9543 >> 128; if (x & 0x80000000000000 > 0) result = result * 0x10058C86DA1C09EA1FF19D294CF2F679B >> 128; if (x & 0x40000000000000 > 0) result = result * 0x1002C605E2E8CEC506D21BFC89A23A00F >> 128; if (x & 0x20000000000000 > 0) result = result * 0x100162F3904051FA128BCA9C55C31E5DF >> 128; if (x & 0x10000000000000 > 0) result = result * 0x1000B175EFFDC76BA38E31671CA939725 >> 128; if (x & 0x8000000000000 > 0) result = result * 0x100058BA01FB9F96D6CACD4B180917C3D >> 128; if (x & 0x4000000000000 > 0) result = result * 0x10002C5CC37DA9491D0985C348C68E7B3 >> 128; if (x & 0x2000000000000 > 0) result = result * 0x1000162E525EE054754457D5995292026 >> 128; if (x & 0x1000000000000 > 0) result = result * 0x10000B17255775C040618BF4A4ADE83FC >> 128; if (x & 0x800000000000 > 0) result = result * 0x1000058B91B5BC9AE2EED81E9B7D4CFAB >> 128; if (x & 0x400000000000 > 0) result = result * 0x100002C5C89D5EC6CA4D7C8ACC017B7C9 >> 128; if (x & 0x200000000000 > 0) result = result * 0x10000162E43F4F831060E02D839A9D16D >> 128; if (x & 0x100000000000 > 0) result = result * 0x100000B1721BCFC99D9F890EA06911763 >> 128; if (x & 0x80000000000 > 0) result = result * 0x10000058B90CF1E6D97F9CA14DBCC1628 >> 128; if (x & 0x40000000000 > 0) result = result * 0x1000002C5C863B73F016468F6BAC5CA2B >> 128; if (x & 0x20000000000 > 0) result = result * 0x100000162E430E5A18F6119E3C02282A5 >> 128; if (x & 0x10000000000 > 0) result = result * 0x1000000B1721835514B86E6D96EFD1BFE >> 128; if (x & 0x8000000000 > 0) result = result * 0x100000058B90C0B48C6BE5DF846C5B2EF >> 128; if (x & 0x4000000000 > 0) result = result * 0x10000002C5C8601CC6B9E94213C72737A >> 128; if (x & 0x2000000000 > 0) result = result * 0x1000000162E42FFF037DF38AA2B219F06 >> 128; if (x & 0x1000000000 > 0) result = result * 0x10000000B17217FBA9C739AA5819F44F9 >> 128; if (x & 0x800000000 > 0) result = result * 0x1000000058B90BFCDEE5ACD3C1CEDC823 >> 128; if (x & 0x400000000 > 0) result = result * 0x100000002C5C85FE31F35A6A30DA1BE50 >> 128; if (x & 0x200000000 > 0) result = result * 0x10000000162E42FF0999CE3541B9FFFCF >> 128; if (x & 0x100000000 > 0) result = result * 0x100000000B17217F80F4EF5AADDA45554 >> 128; if (x & 0x80000000 > 0) result = result * 0x10000000058B90BFBF8479BD5A81B51AD >> 128; if (x & 0x40000000 > 0) result = result * 0x1000000002C5C85FDF84BD62AE30A74CC >> 128; if (x & 0x20000000 > 0) result = result * 0x100000000162E42FEFB2FED257559BDAA >> 128; if (x & 0x10000000 > 0) result = result * 0x1000000000B17217F7D5A7716BBA4A9AE >> 128; if (x & 0x8000000 > 0) result = result * 0x100000000058B90BFBE9DDBAC5E109CCE >> 128; if (x & 0x4000000 > 0) result = result * 0x10000000002C5C85FDF4B15DE6F17EB0D >> 128; if (x & 0x2000000 > 0) result = result * 0x1000000000162E42FEFA494F1478FDE05 >> 128; if (x & 0x1000000 > 0) result = result * 0x10000000000B17217F7D20CF927C8E94C >> 128; if (x & 0x800000 > 0) result = result * 0x1000000000058B90BFBE8F71CB4E4B33D >> 128; if (x & 0x400000 > 0) result = result * 0x100000000002C5C85FDF477B662B26945 >> 128; if (x & 0x200000 > 0) result = result * 0x10000000000162E42FEFA3AE53369388C >> 128; if (x & 0x100000 > 0) result = result * 0x100000000000B17217F7D1D351A389D40 >> 128; if (x & 0x80000 > 0) result = result * 0x10000000000058B90BFBE8E8B2D3D4EDE >> 128; if (x & 0x40000 > 0) result = result * 0x1000000000002C5C85FDF4741BEA6E77E >> 128; if (x & 0x20000 > 0) result = result * 0x100000000000162E42FEFA39FE95583C2 >> 128; if (x & 0x10000 > 0) result = result * 0x1000000000000B17217F7D1CFB72B45E1 >> 128; if (x & 0x8000 > 0) result = result * 0x100000000000058B90BFBE8E7CC35C3F0 >> 128; if (x & 0x4000 > 0) result = result * 0x10000000000002C5C85FDF473E242EA38 >> 128; if (x & 0x2000 > 0) result = result * 0x1000000000000162E42FEFA39F02B772C >> 128; if (x & 0x1000 > 0) result = result * 0x10000000000000B17217F7D1CF7D83C1A >> 128; if (x & 0x800 > 0) result = result * 0x1000000000000058B90BFBE8E7BDCBE2E >> 128; if (x & 0x400 > 0) result = result * 0x100000000000002C5C85FDF473DEA871F >> 128; if (x & 0x200 > 0) result = result * 0x10000000000000162E42FEFA39EF44D91 >> 128; if (x & 0x100 > 0) result = result * 0x100000000000000B17217F7D1CF79E949 >> 128; if (x & 0x80 > 0) result = result * 0x10000000000000058B90BFBE8E7BCE544 >> 128; if (x & 0x40 > 0) result = result * 0x1000000000000002C5C85FDF473DE6ECA >> 128; if (x & 0x20 > 0) result = result * 0x100000000000000162E42FEFA39EF366F >> 128; if (x & 0x10 > 0) result = result * 0x1000000000000000B17217F7D1CF79AFA >> 128; if (x & 0x8 > 0) result = result * 0x100000000000000058B90BFBE8E7BCD6D >> 128; if (x & 0x4 > 0) result = result * 0x10000000000000002C5C85FDF473DE6B2 >> 128; if (x & 0x2 > 0) result = result * 0x1000000000000000162E42FEFA39EF358 >> 128; if (x & 0x1 > 0) result = result * 0x10000000000000000B17217F7D1CF79AB >> 128; result >>= uint256 (int256 (63 - (x >> 64))); require (result <= uint256 (int256 (MAX_64x64))); return int128 (int256 (result)); } } /** * Calculate natural exponent of x. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function exp (int128 x) internal pure returns (int128) { unchecked { require (x < 0x400000000000000000); // Overflow if (x < -0x400000000000000000) return 0; // Underflow return exp_2 ( int128 (int256 (x) * 0x171547652B82FE1777D0FFDA0D23A7D12 >> 128)); } } /** * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit * integer numbers. Revert on overflow or when y is zero. * * @param x unsigned 256-bit integer number * @param y unsigned 256-bit integer number * @return unsigned 64.64-bit fixed point number */ function divuu (uint256 x, uint256 y) private pure returns (uint128) { unchecked { require (y != 0); uint256 result; if (x <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) result = (x << 64) / y; else { uint256 msb = 192; uint256 xc = x >> 192; if (xc >= 0x100000000) { xc >>= 32; msb += 32; } if (xc >= 0x10000) { xc >>= 16; msb += 16; } if (xc >= 0x100) { xc >>= 8; msb += 8; } if (xc >= 0x10) { xc >>= 4; msb += 4; } if (xc >= 0x4) { xc >>= 2; msb += 2; } if (xc >= 0x2) msb += 1; // No need to shift xc anymore result = (x << 255 - msb) / ((y - 1 >> msb - 191) + 1); require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); uint256 hi = result * (y >> 128); uint256 lo = result * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); uint256 xh = x >> 192; uint256 xl = x << 64; if (xl < lo) xh -= 1; xl -= lo; // We rely on overflow behavior here lo = hi << 128; if (xl < lo) xh -= 1; xl -= lo; // We rely on overflow behavior here assert (xh == hi >> 128); result += xl / y; } require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); return uint128 (result); } } /** * Calculate sqrt (x) rounding down, where x is unsigned 256-bit integer * number. * * @param x unsigned 256-bit integer number * @return unsigned 128-bit integer number */ function sqrtu (uint256 x) private pure returns (uint128) { unchecked { if (x == 0) return 0; else { uint256 xx = x; uint256 r = 1; if (xx >= 0x100000000000000000000000000000000) { xx >>= 128; r <<= 64; } if (xx >= 0x10000000000000000) { xx >>= 64; r <<= 32; } if (xx >= 0x100000000) { xx >>= 32; r <<= 16; } if (xx >= 0x10000) { xx >>= 16; r <<= 8; } if (xx >= 0x100) { xx >>= 8; r <<= 4; } if (xx >= 0x10) { xx >>= 4; r <<= 2; } if (xx >= 0x8) { r <<= 1; } r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; // Seven iterations should be enough uint256 r1 = x / r; return uint128 (r < r1 ? r : r1); } } } }
pragma solidity ^0.8.4; // SPDX-License-Identifier: GPL-3.0-or-later import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; /** * Created and owned by the staking contract. * * It mints and burns OGTemple as users stake/unstake */ contract OGTemple is ERC20, ERC20Burnable, Ownable { constructor() ERC20("OGTemple", "OG_TEMPLE") {} function mint(address to, uint256 amount) external onlyOwner { _mint(to, amount); } }
{ "optimizer": { "enabled": true, "runs": 999999 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"contract IERC20","name":"_templeToken","type":"address"},{"internalType":"contract ExitQueue","name":"_exitQueue","type":"address"},{"internalType":"contract TempleStaking","name":"_staking","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"accelerationStartAtEpoch","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentEpoch","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"disableAcceleratedExitQueue","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"epochAccelerationFactorDenominator","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"epochAccelerationFactorNumerator","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"exitQueue","outputs":[{"internalType":"contract ExitQueue","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_exiter","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"join","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"epochs","type":"uint256[]"},{"internalType":"uint256","name":"length","type":"uint256"}],"name":"restake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"numerator","type":"uint256"},{"internalType":"uint256","name":"denominator","type":"uint256"},{"internalType":"uint256","name":"startAtEpoch","type":"uint256"}],"name":"setAccelerationPolicy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_epochSize","type":"uint256"}],"name":"setEpochSize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxPerAddress","type":"uint256"}],"name":"setMaxPerAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxPerEpoch","type":"uint256"}],"name":"setMaxPerEpoch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_users","type":"address[]"},{"internalType":"uint256[]","name":"_amounts","type":"uint256[]"}],"name":"setOwedTemple","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"staking","outputs":[{"internalType":"contract TempleStaking","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"templeToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"epochs","type":"uint256[]"},{"internalType":"uint256","name":"length","type":"uint256"}],"name":"withdrawEpochs","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
6080604052600560045560046005556113886006553480156200002157600080fd5b5060405162002023380380620020238339810160408190526200004491620000e2565b6200004f3362000092565b600380546001600160a01b039485166001600160a01b0319918216179091556001805493851693821693909317909255600280549190931691161790556200014e565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600080600060608486031215620000f7578283fd5b8351620001048162000135565b6020850151909350620001178162000135565b60408501519092506200012a8162000135565b809150509250925092565b6001600160a01b03811681146200014b57600080fd5b50565b611ec5806200015e6000396000f3fe608060405234801561001057600080fd5b50600436106101515760003560e01c80637bddd65b116100cd578063b1a9069c11610081578063f2fde38b11610066578063f2fde38b146102a6578063f7b5ef78146102b9578063ffed4bf5146102cc57600080fd5b8063b1a9069c14610273578063d0761ac01461029357600080fd5b8063a5df1be1116100b2578063a5df1be11461024e578063a7b1f41714610257578063aaebf6991461026057600080fd5b80637bddd65b1461021d5780638da5cb5b1461023057600080fd5b80633b4da69f11610124578063525a5f5c11610109578063525a5f5c14610205578063715018a61461020d578063766718081461021557600080fd5b80633b4da69f146101ad5780634cf088d9146101c057600080fd5b8063111b60a9146101565780631655d3501461016b57806316a461a01461017e5780632d6184a414610191575b600080fd5b610169610164366004611b2c565b6102ec565b005b610169610179366004611962565b610380565b61016961018c366004611a23565b61048f565b61019a60055481565b6040519081526020015b60405180910390f35b6101696101bb366004611939565b6106d7565b6002546101e09073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101a4565b610169610781565b6101696108bf565b61019a61094c565b61016961022b366004611afc565b610a37565b60005473ffffffffffffffffffffffffffffffffffffffff166101e0565b61019a60065481565b61019a60045481565b61016961026e366004611afc565b610b39565b6003546101e09073ffffffffffffffffffffffffffffffffffffffff1681565b6101696102a1366004611a99565b610c11565b6101696102b436600461191f565b610e3b565b6101696102c7366004611afc565b610f6b565b6001546101e09073ffffffffffffffffffffffffffffffffffffffff1681565b60005473ffffffffffffffffffffffffffffffffffffffff163314610372576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b600492909255600555600655565b60005473ffffffffffffffffffffffffffffffffffffffff163314610401576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610369565b6001546040517f1655d35000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90911690631655d350906104599085908590600401611bf6565b600060405180830381600087803b15801561047357600080fd5b505af1158015610487573d6000803e3d6000fd5b505050505050565b6000805b828110156105bb5760015473ffffffffffffffffffffffffffffffffffffffff16630404cc27338787858181106104f3577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e087901b16815273ffffffffffffffffffffffffffffffffffffffff9094166004850152602002919091013560248301525060440160206040518083038186803b15801561056557600080fd5b505afa158015610579573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061059d9190611b14565b6105a79083611d27565b9150806105b381611df8565b915050610493565b506105fc8484808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152508692508591506110439050565b6003546002546106269173ffffffffffffffffffffffffffffffffffffffff9081169116836112d6565b6002546040517f2ee409080000000000000000000000000000000000000000000000000000000081523360048201526024810183905273ffffffffffffffffffffffffffffffffffffffff90911690632ee4090890604401602060405180830381600087803b15801561069857600080fd5b505af11580156106ac573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106d09190611b14565b5050505050565b60015473ffffffffffffffffffffffffffffffffffffffff163314610758576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f6f6e6c79206578697420717565756500000000000000000000000000000000006044820152606401610369565b60035461077d9073ffffffffffffffffffffffffffffffffffffffff16333084611461565b5050565b60005473ffffffffffffffffffffffffffffffffffffffff163314610802576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610369565b60015473ffffffffffffffffffffffffffffffffffffffff1663f2fde38b61083f60005473ffffffffffffffffffffffffffffffffffffffff1690565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b16815273ffffffffffffffffffffffffffffffffffffffff9091166004820152602401600060405180830381600087803b1580156108a557600080fd5b505af11580156108b9573d6000803e3d6000fd5b50505050565b60005473ffffffffffffffffffffffffffffffffffffffff163314610940576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610369565b61094a60006114bf565b565b600080600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663766718086040518163ffffffff1660e01b815260040160206040518083038186803b1580156109b757600080fd5b505afa1580156109cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109ef9190611b14565b9050600654811015610a0057919050565b600554600454600654610a139084611db5565b610a1d9190611d78565b610a279190611d3f565b610a319082611d27565b91505090565b60005473ffffffffffffffffffffffffffffffffffffffff163314610ab8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610369565b6001546040517f7bddd65b0000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff90911690637bddd65b906024015b600060405180830381600087803b158015610b2557600080fd5b505af11580156106d0573d6000803e3d6000fd5b60005473ffffffffffffffffffffffffffffffffffffffff163314610bba576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610369565b6001546040517faaebf6990000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff9091169063aaebf69990602401610b0b565b600080610c1c61094c565b905060005b83811015610e0b5781858281518110610c63577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015110610cf8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602760248201527f43616e206f6e6c792077697468647261772066726f6d2070726f63657373656460448201527f2065706f636873000000000000000000000000000000000000000000000000006064820152608401610369565b600154855173ffffffffffffffffffffffffffffffffffffffff90911690630404cc27903390889085908110610d57577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200260200101516040518363ffffffff1660e01b8152600401610d9d92919073ffffffffffffffffffffffffffffffffffffffff929092168252602082015260400190565b60206040518083038186803b158015610db557600080fd5b505afa158015610dc9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ded9190611b14565b610df79084611d27565b925080610e0381611df8565b915050610c21565b50610e17848484611043565b6003546108b99073ffffffffffffffffffffffffffffffffffffffff163384611534565b60005473ffffffffffffffffffffffffffffffffffffffff163314610ebc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610369565b73ffffffffffffffffffffffffffffffffffffffff8116610f5f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610369565b610f68816114bf565b50565b60005473ffffffffffffffffffffffffffffffffffffffff163314610fec576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610369565b6001546040517ff7b5ef780000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff9091169063f7b5ef7890602401610b0b565b6003546040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009173ffffffffffffffffffffffffffffffffffffffff16906370a082319060240160206040518083038186803b1580156110ad57600080fd5b505afa1580156110c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110e59190611b14565b6001546040517fd1d8418e00000000000000000000000000000000000000000000000000000000815291925073ffffffffffffffffffffffffffffffffffffffff169063d1d8418e90611142903390889088903090600401611bad565b600060405180830381600087803b15801561115c57600080fd5b505af1158015611170573d6000803e3d6000fd5b50506003546040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015285935084925073ffffffffffffffffffffffffffffffffffffffff909116906370a082319060240160206040518083038186803b1580156111e157600080fd5b505afa1580156111f5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112199190611b14565b6112239190611db5565b146108b9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604d60248201527f42616c616e636520696e6372656173652073686f756c6420626520657175616c60448201527f20746f2061207573657227732062616720666f72206120676976656e2065786960648201527f742071756575652065706f636800000000000000000000000000000000000000608482015260a401610369565b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8381166024830152600091839186169063dd62ed3e9060440160206040518083038186803b15801561134857600080fd5b505afa15801561135c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113809190611b14565b61138a9190611d27565b60405173ffffffffffffffffffffffffffffffffffffffff85166024820152604481018290529091506108b99085907f095ea7b300000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915261158f565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526108b99085907f23b872dd00000000000000000000000000000000000000000000000000000000906084016113df565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60405173ffffffffffffffffffffffffffffffffffffffff831660248201526044810182905261158a9084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064016113df565b505050565b60006115f1826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661169b9092919063ffffffff16565b80519091501561158a578080602001905181019061160f9190611adc565b61158a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610369565b60606116aa84846000856116b4565b90505b9392505050565b606082471015611746576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610369565b843b6117ae576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610369565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516117d79190611b91565b60006040518083038185875af1925050503d8060008114611814576040519150601f19603f3d011682016040523d82523d6000602084013e611819565b606091505b5091509150611829828286611834565b979650505050505050565b606083156118435750816116ad565b8251156118535782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103699190611c63565b803573ffffffffffffffffffffffffffffffffffffffff811681146118ab57600080fd5b919050565b600082601f8301126118c0578081fd5b813560206118d56118d083611d03565b611cb4565b80838252828201915082860187848660051b89010111156118f4578586fd5b855b85811015611912578135845292840192908401906001016118f6565b5090979650505050505050565b600060208284031215611930578081fd5b6116ad82611887565b6000806040838503121561194b578081fd5b61195483611887565b946020939093013593505050565b60008060408385031215611974578182fd5b823567ffffffffffffffff8082111561198b578384fd5b818501915085601f83011261199e578384fd5b813560206119ae6118d083611d03565b8083825282820191508286018a848660051b89010111156119cd578889fd5b8896505b848710156119f6576119e281611887565b8352600196909601959183019183016119d1565b5096505086013592505080821115611a0c578283fd5b50611a19858286016118b0565b9150509250929050565b600080600060408486031215611a37578081fd5b833567ffffffffffffffff80821115611a4e578283fd5b818601915086601f830112611a61578283fd5b813581811115611a6f578384fd5b8760208260051b8501011115611a83578384fd5b6020928301989097509590910135949350505050565b60008060408385031215611aab578182fd5b823567ffffffffffffffff811115611ac1578283fd5b611acd858286016118b0565b95602094909401359450505050565b600060208284031215611aed578081fd5b815180151581146116ad578182fd5b600060208284031215611b0d578081fd5b5035919050565b600060208284031215611b25578081fd5b5051919050565b600080600060608486031215611b40578283fd5b505081359360208301359350604090920135919050565b6000815180845260208085019450808401835b83811015611b8657815187529582019590820190600101611b6a565b509495945050505050565b60008251611ba3818460208701611dcc565b9190910192915050565b600073ffffffffffffffffffffffffffffffffffffffff808716835260806020840152611bdd6080840187611b57565b6040840195909552929092166060909101525092915050565b604080825283519082018190526000906020906060840190828701845b82811015611c4557815173ffffffffffffffffffffffffffffffffffffffff1684529284019290840190600101611c13565b50505083810382850152611c598186611b57565b9695505050505050565b6020815260008251806020840152611c82816040850160208701611dcc565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611cfb57611cfb611e60565b604052919050565b600067ffffffffffffffff821115611d1d57611d1d611e60565b5060051b60200190565b60008219821115611d3a57611d3a611e31565b500190565b600082611d73577f4e487b710000000000000000000000000000000000000000000000000000000081526012600452602481fd5b500490565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615611db057611db0611e31565b500290565b600082821015611dc757611dc7611e31565b500390565b60005b83811015611de7578181015183820152602001611dcf565b838111156108b95750506000910152565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415611e2a57611e2a611e31565b5060010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fdfea26469706673582212203aa98697fb93c2eeaaabf088beb90a88cd13bfe3017d720d7b833c19f9aa6c3464736f6c63430008040033000000000000000000000000470ebf5f030ed85fc1ed4c2d36b9dd02e77cf1b7000000000000000000000000967591888a5e8aed9d2a920fe4cc726e83d2bca90000000000000000000000004d14b24edb751221b3ff08bbb8bd91d4b1c8bc77
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106101515760003560e01c80637bddd65b116100cd578063b1a9069c11610081578063f2fde38b11610066578063f2fde38b146102a6578063f7b5ef78146102b9578063ffed4bf5146102cc57600080fd5b8063b1a9069c14610273578063d0761ac01461029357600080fd5b8063a5df1be1116100b2578063a5df1be11461024e578063a7b1f41714610257578063aaebf6991461026057600080fd5b80637bddd65b1461021d5780638da5cb5b1461023057600080fd5b80633b4da69f11610124578063525a5f5c11610109578063525a5f5c14610205578063715018a61461020d578063766718081461021557600080fd5b80633b4da69f146101ad5780634cf088d9146101c057600080fd5b8063111b60a9146101565780631655d3501461016b57806316a461a01461017e5780632d6184a414610191575b600080fd5b610169610164366004611b2c565b6102ec565b005b610169610179366004611962565b610380565b61016961018c366004611a23565b61048f565b61019a60055481565b6040519081526020015b60405180910390f35b6101696101bb366004611939565b6106d7565b6002546101e09073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101a4565b610169610781565b6101696108bf565b61019a61094c565b61016961022b366004611afc565b610a37565b60005473ffffffffffffffffffffffffffffffffffffffff166101e0565b61019a60065481565b61019a60045481565b61016961026e366004611afc565b610b39565b6003546101e09073ffffffffffffffffffffffffffffffffffffffff1681565b6101696102a1366004611a99565b610c11565b6101696102b436600461191f565b610e3b565b6101696102c7366004611afc565b610f6b565b6001546101e09073ffffffffffffffffffffffffffffffffffffffff1681565b60005473ffffffffffffffffffffffffffffffffffffffff163314610372576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b600492909255600555600655565b60005473ffffffffffffffffffffffffffffffffffffffff163314610401576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610369565b6001546040517f1655d35000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90911690631655d350906104599085908590600401611bf6565b600060405180830381600087803b15801561047357600080fd5b505af1158015610487573d6000803e3d6000fd5b505050505050565b6000805b828110156105bb5760015473ffffffffffffffffffffffffffffffffffffffff16630404cc27338787858181106104f3577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e087901b16815273ffffffffffffffffffffffffffffffffffffffff9094166004850152602002919091013560248301525060440160206040518083038186803b15801561056557600080fd5b505afa158015610579573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061059d9190611b14565b6105a79083611d27565b9150806105b381611df8565b915050610493565b506105fc8484808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152508692508591506110439050565b6003546002546106269173ffffffffffffffffffffffffffffffffffffffff9081169116836112d6565b6002546040517f2ee409080000000000000000000000000000000000000000000000000000000081523360048201526024810183905273ffffffffffffffffffffffffffffffffffffffff90911690632ee4090890604401602060405180830381600087803b15801561069857600080fd5b505af11580156106ac573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106d09190611b14565b5050505050565b60015473ffffffffffffffffffffffffffffffffffffffff163314610758576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f6f6e6c79206578697420717565756500000000000000000000000000000000006044820152606401610369565b60035461077d9073ffffffffffffffffffffffffffffffffffffffff16333084611461565b5050565b60005473ffffffffffffffffffffffffffffffffffffffff163314610802576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610369565b60015473ffffffffffffffffffffffffffffffffffffffff1663f2fde38b61083f60005473ffffffffffffffffffffffffffffffffffffffff1690565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b16815273ffffffffffffffffffffffffffffffffffffffff9091166004820152602401600060405180830381600087803b1580156108a557600080fd5b505af11580156108b9573d6000803e3d6000fd5b50505050565b60005473ffffffffffffffffffffffffffffffffffffffff163314610940576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610369565b61094a60006114bf565b565b600080600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663766718086040518163ffffffff1660e01b815260040160206040518083038186803b1580156109b757600080fd5b505afa1580156109cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109ef9190611b14565b9050600654811015610a0057919050565b600554600454600654610a139084611db5565b610a1d9190611d78565b610a279190611d3f565b610a319082611d27565b91505090565b60005473ffffffffffffffffffffffffffffffffffffffff163314610ab8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610369565b6001546040517f7bddd65b0000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff90911690637bddd65b906024015b600060405180830381600087803b158015610b2557600080fd5b505af11580156106d0573d6000803e3d6000fd5b60005473ffffffffffffffffffffffffffffffffffffffff163314610bba576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610369565b6001546040517faaebf6990000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff9091169063aaebf69990602401610b0b565b600080610c1c61094c565b905060005b83811015610e0b5781858281518110610c63577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015110610cf8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602760248201527f43616e206f6e6c792077697468647261772066726f6d2070726f63657373656460448201527f2065706f636873000000000000000000000000000000000000000000000000006064820152608401610369565b600154855173ffffffffffffffffffffffffffffffffffffffff90911690630404cc27903390889085908110610d57577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200260200101516040518363ffffffff1660e01b8152600401610d9d92919073ffffffffffffffffffffffffffffffffffffffff929092168252602082015260400190565b60206040518083038186803b158015610db557600080fd5b505afa158015610dc9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ded9190611b14565b610df79084611d27565b925080610e0381611df8565b915050610c21565b50610e17848484611043565b6003546108b99073ffffffffffffffffffffffffffffffffffffffff163384611534565b60005473ffffffffffffffffffffffffffffffffffffffff163314610ebc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610369565b73ffffffffffffffffffffffffffffffffffffffff8116610f5f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610369565b610f68816114bf565b50565b60005473ffffffffffffffffffffffffffffffffffffffff163314610fec576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610369565b6001546040517ff7b5ef780000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff9091169063f7b5ef7890602401610b0b565b6003546040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009173ffffffffffffffffffffffffffffffffffffffff16906370a082319060240160206040518083038186803b1580156110ad57600080fd5b505afa1580156110c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110e59190611b14565b6001546040517fd1d8418e00000000000000000000000000000000000000000000000000000000815291925073ffffffffffffffffffffffffffffffffffffffff169063d1d8418e90611142903390889088903090600401611bad565b600060405180830381600087803b15801561115c57600080fd5b505af1158015611170573d6000803e3d6000fd5b50506003546040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015285935084925073ffffffffffffffffffffffffffffffffffffffff909116906370a082319060240160206040518083038186803b1580156111e157600080fd5b505afa1580156111f5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112199190611b14565b6112239190611db5565b146108b9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604d60248201527f42616c616e636520696e6372656173652073686f756c6420626520657175616c60448201527f20746f2061207573657227732062616720666f72206120676976656e2065786960648201527f742071756575652065706f636800000000000000000000000000000000000000608482015260a401610369565b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8381166024830152600091839186169063dd62ed3e9060440160206040518083038186803b15801561134857600080fd5b505afa15801561135c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113809190611b14565b61138a9190611d27565b60405173ffffffffffffffffffffffffffffffffffffffff85166024820152604481018290529091506108b99085907f095ea7b300000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915261158f565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526108b99085907f23b872dd00000000000000000000000000000000000000000000000000000000906084016113df565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60405173ffffffffffffffffffffffffffffffffffffffff831660248201526044810182905261158a9084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064016113df565b505050565b60006115f1826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661169b9092919063ffffffff16565b80519091501561158a578080602001905181019061160f9190611adc565b61158a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610369565b60606116aa84846000856116b4565b90505b9392505050565b606082471015611746576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610369565b843b6117ae576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610369565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516117d79190611b91565b60006040518083038185875af1925050503d8060008114611814576040519150601f19603f3d011682016040523d82523d6000602084013e611819565b606091505b5091509150611829828286611834565b979650505050505050565b606083156118435750816116ad565b8251156118535782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103699190611c63565b803573ffffffffffffffffffffffffffffffffffffffff811681146118ab57600080fd5b919050565b600082601f8301126118c0578081fd5b813560206118d56118d083611d03565b611cb4565b80838252828201915082860187848660051b89010111156118f4578586fd5b855b85811015611912578135845292840192908401906001016118f6565b5090979650505050505050565b600060208284031215611930578081fd5b6116ad82611887565b6000806040838503121561194b578081fd5b61195483611887565b946020939093013593505050565b60008060408385031215611974578182fd5b823567ffffffffffffffff8082111561198b578384fd5b818501915085601f83011261199e578384fd5b813560206119ae6118d083611d03565b8083825282820191508286018a848660051b89010111156119cd578889fd5b8896505b848710156119f6576119e281611887565b8352600196909601959183019183016119d1565b5096505086013592505080821115611a0c578283fd5b50611a19858286016118b0565b9150509250929050565b600080600060408486031215611a37578081fd5b833567ffffffffffffffff80821115611a4e578283fd5b818601915086601f830112611a61578283fd5b813581811115611a6f578384fd5b8760208260051b8501011115611a83578384fd5b6020928301989097509590910135949350505050565b60008060408385031215611aab578182fd5b823567ffffffffffffffff811115611ac1578283fd5b611acd858286016118b0565b95602094909401359450505050565b600060208284031215611aed578081fd5b815180151581146116ad578182fd5b600060208284031215611b0d578081fd5b5035919050565b600060208284031215611b25578081fd5b5051919050565b600080600060608486031215611b40578283fd5b505081359360208301359350604090920135919050565b6000815180845260208085019450808401835b83811015611b8657815187529582019590820190600101611b6a565b509495945050505050565b60008251611ba3818460208701611dcc565b9190910192915050565b600073ffffffffffffffffffffffffffffffffffffffff808716835260806020840152611bdd6080840187611b57565b6040840195909552929092166060909101525092915050565b604080825283519082018190526000906020906060840190828701845b82811015611c4557815173ffffffffffffffffffffffffffffffffffffffff1684529284019290840190600101611c13565b50505083810382850152611c598186611b57565b9695505050505050565b6020815260008251806020840152611c82816040850160208701611dcc565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611cfb57611cfb611e60565b604052919050565b600067ffffffffffffffff821115611d1d57611d1d611e60565b5060051b60200190565b60008219821115611d3a57611d3a611e31565b500190565b600082611d73577f4e487b710000000000000000000000000000000000000000000000000000000081526012600452602481fd5b500490565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615611db057611db0611e31565b500290565b600082821015611dc757611dc7611e31565b500390565b60005b83811015611de7578181015183820152602001611dcf565b838111156108b95750506000910152565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415611e2a57611e2a611e31565b5060010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fdfea26469706673582212203aa98697fb93c2eeaaabf088beb90a88cd13bfe3017d720d7b833c19f9aa6c3464736f6c63430008040033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000470ebf5f030ed85fc1ed4c2d36b9dd02e77cf1b7000000000000000000000000967591888a5e8aed9d2a920fe4cc726e83d2bca90000000000000000000000004d14b24edb751221b3ff08bbb8bd91d4b1c8bc77
-----Decoded View---------------
Arg [0] : _templeToken (address): 0x470EBf5f030Ed85Fc1ed4C2d36B9DD02e77CF1b7
Arg [1] : _exitQueue (address): 0x967591888A5e8aED9D2A920fE4cC726e83d2bca9
Arg [2] : _staking (address): 0x4D14b24EDb751221B3Ff08BBB8bd91D4b1c8bc77
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 000000000000000000000000470ebf5f030ed85fc1ed4c2d36b9dd02e77cf1b7
Arg [1] : 000000000000000000000000967591888a5e8aed9d2a920fe4cc726e83d2bca9
Arg [2] : 0000000000000000000000004d14b24edb751221b3ff08bbb8bd91d4b1c8bc77
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.