More Info
Private Name Tags
ContractCreator
Latest 25 from a total of 469 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Withdraw Multipl... | 21576571 | 4 days ago | IN | 0 ETH | 0.00089713 | ||||
Withdraw Multipl... | 21576486 | 4 days ago | IN | 0 ETH | 0.00083844 | ||||
Withdraw Multipl... | 21564715 | 6 days ago | IN | 0 ETH | 0.00088309 | ||||
Withdraw Multipl... | 21564688 | 6 days ago | IN | 0 ETH | 0.00084341 | ||||
Withdraw Multipl... | 21521213 | 12 days ago | IN | 0 ETH | 0.00112463 | ||||
Withdraw Multipl... | 21516087 | 13 days ago | IN | 0 ETH | 0.00171081 | ||||
Withdraw Multipl... | 21515602 | 13 days ago | IN | 0 ETH | 0.00104994 | ||||
Withdraw Multipl... | 21514251 | 13 days ago | IN | 0 ETH | 0.00041191 | ||||
Withdraw Multipl... | 21514224 | 13 days ago | IN | 0 ETH | 0.00037277 | ||||
Withdraw Multipl... | 21514142 | 13 days ago | IN | 0 ETH | 0.00038085 | ||||
Withdraw Multipl... | 21514074 | 13 days ago | IN | 0 ETH | 0.00041284 | ||||
Withdraw Multipl... | 21512208 | 13 days ago | IN | 0 ETH | 0.00063275 | ||||
Withdraw Multipl... | 21508310 | 14 days ago | IN | 0 ETH | 0.00053217 | ||||
Withdraw Multipl... | 21508284 | 14 days ago | IN | 0 ETH | 0.00060334 | ||||
Withdraw Multipl... | 21508270 | 14 days ago | IN | 0 ETH | 0.00011288 | ||||
Withdraw Multipl... | 21438797 | 23 days ago | IN | 0 ETH | 0.00665282 | ||||
Withdraw Multipl... | 21420259 | 26 days ago | IN | 0 ETH | 0.0011224 | ||||
Withdraw Multipl... | 21413324 | 27 days ago | IN | 0 ETH | 0.00074766 | ||||
Withdraw Multipl... | 21399323 | 29 days ago | IN | 0 ETH | 0.00121518 | ||||
Withdraw Multipl... | 21367909 | 33 days ago | IN | 0 ETH | 0.00915983 | ||||
Withdraw Multipl... | 21367867 | 33 days ago | IN | 0 ETH | 0.00677305 | ||||
Withdraw Multipl... | 21367842 | 33 days ago | IN | 0 ETH | 0.0075502 | ||||
Withdraw Multipl... | 21367740 | 33 days ago | IN | 0 ETH | 0.00780112 | ||||
Withdraw Multipl... | 21352117 | 36 days ago | IN | 0 ETH | 0.00208065 | ||||
Withdraw Multipl... | 21333949 | 38 days ago | IN | 0 ETH | 0.00264137 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Name:
DistributorTokenLock
Compiler Version
v0.8.19+commit.7dd6d404
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.19; import "./DistributorRegistry.sol"; import "./TokenUtilityAccounting.sol"; import "./BaseTokenLock.sol"; import "./utils/ProtocolSigningUtils.sol"; /** * @title DistributorTokenLock * @author NFTfi * @dev This contract allows users to lock tokens with a request-based withdrawal mechanism. Withdrawals * have cooldown periods and need a protocol signature if the tokens withdrawn come from the distributor * and not from an external source. It integrates with a `TokenUtilityAccounting` contract. */ contract DistributorTokenLock is BaseTokenLock { DistributorRegistry public immutable distributorRegistry; address public protocolSignerAddress; /** * @dev Initializes the contract, setting initial admin, token, distributor, and cooldown values. * @param _admin Admin's address. * @param _nftfi Address of the NFTFI token. * @param _distributorRegistry MerkleDistributor contract address. * @param _protocolSignerAddress protocol signature checking feature can be turned off by setting it to 0 address * @param _cooldown Cooldown time in seconds. */ constructor( address _admin, address _nftfi, address _distributorRegistry, address _tokenUtilityAccounting, address _protocolSignerAddress, uint256 _cooldown ) BaseTokenLock(_admin, _nftfi, _tokenUtilityAccounting, _cooldown) { distributorRegistry = DistributorRegistry(_distributorRegistry); protocolSignerAddress = _protocolSignerAddress; } /** * @dev Allows the distributor to lock tokens on behalf of a beneficiary (claimer). * Only callable by the distributor, requests a withdrawal for the user for the * full amount automatically, so cooldown starts at claim time. * User gets no "utility points" (TokenUtilityAccounting) except if they delete the created request. * @param _amount Amount of tokens to lock. * @param _beneficiary Address of the beneficiary. */ function lockTokens(uint256 _amount, address _beneficiary) external { require(distributorRegistry.isDistributor(msg.sender), "Only registered distributor"); _lockTokens(_amount, _beneficiary); _requestWithdrawal(_amount, _beneficiary); } /** * @dev Allows a user to withdraw their tokens after a cooldown, * with a protocol signature if we withdraw from the ditributor locked pot. * @param _amount Amount of tokens to withdraw. * @param _requestTimestamp Timestamp of the original withdrawal request. * @param _protocolSignatureExpiry The timestamp after which the signature is considered expired and invalid. * Not checked if we withdraw from the non-ditributor locked pot. * Can be left with 0 values in that case. * @param _protocolSignature The actual ECDSA signature bytes of the signed data * Not checked if we withdraw from the non-ditributor locked pot. * Can be left with 0 values in that case. */ function withdraw( uint256 _amount, uint256 _requestTimestamp, uint256 _protocolSignatureExpiry, bytes calldata _protocolSignature ) public { if (protocolSignerAddress != address(0)) { require( ProtocolSigningUtils.isValidProtocolSignature( msg.sender, _amount, _requestTimestamp, ProtocolSigningUtils.ProtocolSignature({ expiry: _protocolSignatureExpiry, signer: protocolSignerAddress, signature: _protocolSignature }) ), "Protocol signature invalid" ); } _withdraw(_amount, _requestTimestamp); tokenUtilityAccounting.unlock(msg.sender, _amount); } function withdrawMultiple( uint256[] calldata _amounts, uint256[] calldata _requestTimestamps, uint256[] calldata _protocolSignatureExpiries, bytes[] calldata _protocolSignatures ) external { require(_amounts.length == _requestTimestamps.length, "parameter arity mismatch"); require(_amounts.length == _requestTimestamps.length, "parameter arity mismatch 2"); require(_amounts.length == _requestTimestamps.length, "parameter arity mismatch 3"); for (uint256 i = 0; i < _amounts.length; ++i) { withdraw(_amounts[i], _requestTimestamps[i], _protocolSignatureExpiries[i], _protocolSignatures[i]); } } /** * @dev Sets up new protocol signer address, * protocol signature checking feature can be turned off by setting it to 0 address * @param _protocolSignerAddress - */ function setProtocolSignerAddress(address _protocolSignerAddress) external onlyOwner { protocolSignerAddress = _protocolSignerAddress; } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.19; import "./utils/Ownable.sol"; import "./MerkleDistributor.sol"; contract DistributorRegistry is Ownable { mapping(uint256 => address) public distributorsBySeason; mapping(address => bool) public distributors; /** * @dev Struct to represent claim data for batch processing. * @param rootNumber The Merkle root number associated with the claim. * @param index The index within the Merkle tree for this particular claim. * @param amount The amount of tokens to be claimed. * @param merkleProof The Merkle proof associated with the claim to validate it against the root. */ struct MultiClaimData { uint256 seasonNumber; uint256 index; uint256 amount; bytes32[] merkleProof; } event DistributorAdded(uint256 indexed _seasonNumber, address _distributor); event DistributorRemoved(uint256 indexed _seasonNumber, address _distributor); constructor(address _admin) Ownable(_admin) { // solhint-disable-previous-line no-empty-blocks } function addDistributor(uint256 _seasonNumber, address _distributor) external onlyOwner { require(distributorsBySeason[_seasonNumber] == address(0), "Season number already set"); distributorsBySeason[_seasonNumber] = _distributor; distributors[_distributor] = true; emit DistributorAdded(_seasonNumber, _distributor); } function removeDistributor(uint256 _seasonNumber) external onlyOwner { address distributor = distributorsBySeason[_seasonNumber]; delete distributorsBySeason[_seasonNumber]; delete distributors[distributor]; emit DistributorRemoved(_seasonNumber, distributor); } function isDistributor(address _distributor) external view returns (bool) { return distributors[_distributor]; } /** * @dev Supports batch claiming, instead of transferring to the recipient directly, * tokens are locked in the TokenLock contract. * multi claim where amounts are the same will fail with 'duplicate request' (request collision in token lock), * users need to claim one by one on the distributors in this case * @param _claimData An array containing details for each claim the caller wishes to make. */ function multiClaim(MultiClaimData[] memory _claimData) external { for (uint256 i = 0; i < _claimData.length; ++i) { uint256 seasonNumber = _claimData[i].seasonNumber; uint256 index = _claimData[i].index; uint256 amount = _claimData[i].amount; bytes32[] memory merkleProof = _claimData[i].merkleProof; MerkleDistributor(distributorsBySeason[seasonNumber]).claimFromRegistry( index, amount, merkleProof, msg.sender ); } } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.19; import "./utils/Ownable.sol"; /** * @title TokenUtilityAccounting * @author NFTfi * @dev */ contract TokenUtilityAccounting is Ownable { mapping(address => bool) public tokenLocks; mapping(address => uint256) public weightedAvgLockTimes; mapping(address => uint256) public amounts; // these two only needed if we wanted to distribute a finite, // given amount of rewards proportionally for locking times and amounts acrued uint256 public totalWeightedAvgLockTime; uint256 public totalAmount; event Update( address indexed _user, uint256 _weightedAvgLockTime, uint256 _acruedUserAmount, uint256 _totalWeightedAvgLockTime, uint256 _totalAmount ); constructor(address _admin, address[] memory _tokenLockAddresses) Ownable(_admin) { _addTokenLocks(_tokenLockAddresses); } modifier onlyTokenLock() { require(tokenLocks[msg.sender], "Only token lock"); _; } function lock(address _user, uint256 _amount) external onlyTokenLock { _updateUserWeightedAvgLockTime(_user, _amount); _updateTotalWeightedAvgLockTime(_amount); amounts[_user] += _amount; totalAmount += _amount; emit Update(_user, weightedAvgLockTimes[_user], amounts[_user], totalWeightedAvgLockTime, totalAmount); } function unlock(address _user, uint256 _amount) external onlyTokenLock { amounts[_user] -= _amount; totalAmount -= _amount; emit Update(_user, weightedAvgLockTimes[_user], amounts[_user], totalWeightedAvgLockTime, totalAmount); } /** * @dev updates weighted avg lock time for a given user based on the added amount * @param _user - * @param _amount - amount added */ function _updateUserWeightedAvgLockTime(address _user, uint256 _amount) internal { weightedAvgLockTimes[_user] = _calculateWeightedAvgLockTime( _amount, amounts[_user], weightedAvgLockTimes[_user] ); } /** * @dev updates weighted avg lock time for the whole system based on the added amount * @param _amount - amount added */ function _updateTotalWeightedAvgLockTime(uint256 _amount) internal { totalWeightedAvgLockTime = _calculateWeightedAvgLockTime(_amount, totalAmount, totalWeightedAvgLockTime); } /** * @dev calculates weightedAvgMultiplier virtual timestamp value with * a new data point of token _amount weight and the current time * This function is either called by _updateAvgMultiplierStart or has to be called after * an explicit stake() or a deleteWithdrawRequest(), or any other possible instances, * The function takes the existing average and it's weight (existing balance) then calculates * it with the new value and weight with a weighted avg calculation between the 2 datapoints. * @param _amount - amount added * @param _oldAmount - cumulative amount before * @param _oldWeightedAvgLockTime - */ function _calculateWeightedAvgLockTime( uint256 _amount, uint256 _oldAmount, uint256 _oldWeightedAvgLockTime ) internal view returns (uint256) { if (_oldAmount == 0 || _oldWeightedAvgLockTime == 0) { // if we are at initial state with just 1 datapoint return block.timestamp; } else { uint256 totalWeight = _oldAmount + _amount; // weighted avg calculation between the old value and the new lock timestamp return (_oldAmount * _oldWeightedAvgLockTime + _amount * block.timestamp) / totalWeight; } } function _addTokenLocks(address[] memory _tokenLockAddresses) internal { for (uint256 index = 0; index < _tokenLockAddresses.length; ++index) { tokenLocks[_tokenLockAddresses[index]] = true; } } function addTokenLocks(address[] memory _tokenLockAddresses) external onlyOwner { _addTokenLocks(_tokenLockAddresses); } function removeTokenLocks(address[] memory _tokenLockAddresses) external onlyOwner { for (uint256 index = 0; index < _tokenLockAddresses.length; ++index) { tokenLocks[_tokenLockAddresses[index]] = false; } } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.19; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {Pausable} from "@openzeppelin/contracts/security/Pausable.sol"; import "./NFTfiToken.sol"; import "./TokenUtilityAccounting.sol"; import "./utils/Ownable.sol"; /** * @title TokenLock * @author NFTfi * @dev This contract allows users to lock tokens with a request-based withdrawal mechanism. Withdrawals * have cooldown periods and need a protocol signature if the tokens withdrawn come from the distributor * and not from an external source. It integrates with a `TokenUtilityAccounting` contract. */ abstract contract BaseTokenLock is Ownable, Pausable { using SafeERC20 for NFTfiToken; // Contract that calculates a token utility score with a (locked) time based multiplier. // Optional, can be left zero-address and added in the future. TokenUtilityAccounting public tokenUtilityAccounting; NFTfiToken public immutable nftfiToken; // Cooldown time before a withdrawal can be executed in seconds uint256 public cooldown; mapping(address => uint256) public lockedTokens; mapping(address => uint256) public withdrawalRequestAmounts; mapping(bytes32 => bool) public withdrawRequests; /** * @dev Emitted when tokens are locked in the contract. * @param _amount The amount of tokens locked. * @param _user Address of the user who locked the tokens. */ event Locked(uint256 _amount, address indexed _user); /** * @dev Emitted when a user requests to withdraw their tokens. * @param _amount The amount of tokens the user wants to withdraw. * @param _user Address of the user requesting the withdrawal. */ event WithdrawalRequested(uint256 _amount, address indexed _user, uint256 _timestamp); /** * @dev Emitted when a user withdraws their tokens. * @param _amount The amount of tokens withdrawn. * @param _user Address of the user making the withdrawal. */ event Withdrawn(uint256 _amount, address indexed _user); /** * @dev Emitted when a user's withdrawal request is deleted. * @param _amount The amount of tokens the user initially wanted to withdraw. * @param _user Address of the user whose request was deleted. * @param _timestamp When request was made (unix timstamp in seconds) */ event WithdrawalRequestDeleted(uint256 _amount, address indexed _user, uint256 _timestamp); /** * @dev Initializes the contract, setting initial admin, token, distributor, and cooldown values. * @param _admin Admin's address. * @param _nftfiToken Address of the NFTFI token. * @param _cooldown Cooldown time in seconds. */ constructor( address _admin, address _nftfiToken, address _tokenUtilityAccounting, uint256 _cooldown ) Ownable(_admin) { nftfiToken = NFTfiToken(_nftfiToken); tokenUtilityAccounting = TokenUtilityAccounting(_tokenUtilityAccounting); cooldown = _cooldown; } /** * @dev Internal function to handle locking of tokens. * @param _amount Amount of tokens to lock. * @param _beneficiary Address for whom the tokens are being locked. */ function _lockTokens(uint256 _amount, address _beneficiary) internal whenNotPaused { lockedTokens[_beneficiary] += _amount; tokenUtilityAccounting.lock(_beneficiary, _amount); nftfiToken.safeTransferFrom(msg.sender, address(this), _amount); emit Locked(_amount, _beneficiary); } /** * @dev Internal request, makes it possible that we request a withdrawal right away * after tokens are claimed without locking and unlocking. * @param _amount Amount of tokens to request for withdrawal. */ function _requestWithdrawal(uint256 _amount, address _beneficiary) internal whenNotPaused { require( _amount + withdrawalRequestAmounts[_beneficiary] <= lockedTokens[_beneficiary], "request amounts > total" ); bytes32 requestHash = _calculateRequestHash(_amount, _beneficiary, block.timestamp); require(!withdrawRequests[requestHash], "duplicate request"); withdrawalRequestAmounts[_beneficiary] += _amount; withdrawRequests[requestHash] = true; emit WithdrawalRequested(_amount, _beneficiary, block.timestamp); } function _checkAndDeleteRequest( uint256 _amount, address _beneficiary, uint256 _requestTimestamp ) internal whenNotPaused { bytes32 requestHash = _calculateRequestHash(_amount, _beneficiary, _requestTimestamp); require(withdrawRequests[requestHash], "no request"); require(_amount <= withdrawalRequestAmounts[msg.sender], "amount > requestAmounts"); delete withdrawRequests[requestHash]; withdrawalRequestAmounts[msg.sender] -= _amount; emit WithdrawalRequestDeleted(_amount, msg.sender, _requestTimestamp); } /** * @dev Allows a user to withdraw their tokens after a cooldown, * with a protocol signature if we withdraw from the ditributor locked pot. * @param _amount Amount of tokens to withdraw. * @param _requestTimestamp Timestamp of the original withdrawal request. */ function _withdraw(uint256 _amount, uint256 _requestTimestamp) internal whenNotPaused { require(_amount <= lockedTokens[msg.sender], "withdraw amount > total"); // cooldown checking feature can be turned off by setting it to 0 if (cooldown > 0) { require(block.timestamp >= _requestTimestamp + cooldown, "cooldown not up"); _checkAndDeleteRequest(_amount, msg.sender, _requestTimestamp); } if (cooldown == 0) { if (withdrawalRequestAmounts[msg.sender] > 0) { // if cooldown is disabled, we have to delete existing // cooldowns, otherwise re-using it will cause anomalies _checkAndDeleteRequest(_amount, msg.sender, _requestTimestamp); } else { // if there are no withdrawalRequests anymore, we have to unlock here tokenUtilityAccounting.unlock(msg.sender, _amount); } } lockedTokens[msg.sender] -= _amount; nftfiToken.safeTransfer(msg.sender, _amount); emit Withdrawn(_amount, msg.sender); } /** * @dev Allows the owner to set a new TokenUtilityAccounting contract. * @param _newTokenUtilityAccounting Address of the new TokenUtilityAccounting contract. */ function setTokenUtilityAccounting(address _newTokenUtilityAccounting) external onlyOwner { tokenUtilityAccounting = TokenUtilityAccounting(_newTokenUtilityAccounting); } /** * @dev Sets up new cooldown period * cooldown checking feature can be turned off by setting it to 0 * @param _cooldown - Cooldown time before a withdrawal can be executed after request in seconds */ function setCooldown(uint256 _cooldown) external onlyOwner { cooldown = _cooldown; } /** * @dev Triggers stopped state. * * Requirements: * * - Only the owner can call this method. * - The contract must not be paused. */ function pause() external onlyOwner { _pause(); } /** * @dev Returns to normal state. * * Requirements: * * - Only the owner can call this method. * - The contract must be paused. */ function unpause() external onlyOwner { _unpause(); } /** * @dev Calculates the hash of a withdrawal request. * @param _amount Amount of tokens to withdraw. * @param _user Address of the user. * @param _timestamp Timestamp of the request. * @return Hash of the withdrawal request. */ function _calculateRequestHash( uint256 _amount, address _user, uint256 _timestamp ) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_amount, _user, _timestamp)); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.19; import "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol"; /** * @title ProtocolSigningUtils * @author NFTfi * @notice Helper library for NFTfi. This contract manages verifying signatures * from an NFTfi protocol address to enforce KYC requirements on-chain */ library ProtocolSigningUtils { /** * @dev Signature struct * * @param expiry The timestamp after which the signature is considered expired and invalid. * @param signer Signing protocol address * @param signature The actual ECDSA signature bytes of the signed data */ struct ProtocolSignature { uint256 expiry; address signer; bytes signature; } /* ********* */ /* FUNCTIONS */ /* ********* */ /** * @notice Verifies the validity of a protocol signature. * @dev This function checks whether the protocol signature is valid and hasn't expired. * It constructs a message from the input parameters and verifies its signature against * the expected signer. * * @param _user The address of the user initiating the withdrawal. * @param _amount The amount the user is withdrawing. * @param _requestTimestamp The timestamp when the withdrawal request was made. * @param _protocolSignature - The signature structure containing: * - signer: The address of the signer, in this case and address controlled by the protocol * - expiry: Date when the signature expires * - signature: The ECDSA signature of the protocol, obtained off-chain ahead of time, signing the following * combination of parameters: * - user withdrawing from TokenLock * - amount withdrawn * - requestTimestamp time of the request for the withdrawal to check signature for each individual call * - protocolSignature.signer * - protocolSignature.expiry * @return bool True if the protocol signature is valid; otherwise, false. */ function isValidProtocolSignature( address _user, uint256 _amount, uint256 _requestTimestamp, ProtocolSignature memory _protocolSignature ) internal view returns (bool) { require(block.timestamp <= _protocolSignature.expiry, "Protocol Signature expired"); bytes32 message = keccak256( abi.encodePacked(_user, _amount, _requestTimestamp, _protocolSignature.signer, _protocolSignature.expiry) ); return SignatureChecker.isValidSignatureNow( _protocolSignature.signer, ECDSA.toEthSignedMessageHash(message), _protocolSignature.signature ); } } /** * @title ProtocolSigningUtils * @author NFTfi * @notice Deployable contract for of the above library */ contract ProtocolSigningUtilsContract { /* ********* */ /* FUNCTIONS */ /* ********* */ /** * @notice Verifies the validity of a protocol signature. * @dev This function checks whether the protocol signature is valid and hasn't expired. * It constructs a message from the input parameters and verifies its signature against * the expected signer. * * @param _user The address of the user initiating the withdrawal. * @param _amount The amount the user is withdrawing. * @param _requestTimestamp The timestamp when the withdrawal request was made. * @param _protocolSignature - The signature structure containing: * - signer: The address of the signer, in this case and address controlled by the protocol * - expiry: Date when the signature expires * - signature: The ECDSA signature of the protocol, obtained off-chain ahead of time, signing the following * combination of parameters: * - user withdrawing from TokenLock * - amount withdrawn * - requestTimestamp time of the request for the withdrawal to check signature for each individual call * - protocolSignature.signer * - protocolSignature.expiry * @return bool True if the protocol signature is valid; otherwise, false. */ function isValidProtocolSignature( address _user, uint256 _amount, uint256 _requestTimestamp, ProtocolSigningUtils.ProtocolSignature memory _protocolSignature ) external view returns (bool) { return ProtocolSigningUtils.isValidProtocolSignature(_user, _amount, _requestTimestamp, _protocolSignature); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.19; import "@openzeppelin/contracts/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. * * Modified version from openzeppelin/contracts/access/Ownable.sol that allows to * initialize the owner using a parameter in the constructor */ abstract contract Ownable is Context { address private _owner; address private _ownerCandidate; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor(address _initialOwner) { _setOwner(_initialOwner); } /** * @dev Requests transferring ownership of the contract to a new account (`_newOwnerCandidate`). * Can only be called by the current owner. */ function requestTransferOwnership(address _newOwnerCandidate) public virtual onlyOwner { require(_newOwnerCandidate != address(0), "Ownable: new owner is the zero address"); _ownerCandidate = _newOwnerCandidate; } function acceptTransferOwnership() public virtual { require(_ownerCandidate == _msgSender(), "Ownable: not owner candidate"); _setOwner(_ownerCandidate); delete _ownerCandidate; } function cancelTransferOwnership() public virtual onlyOwner { delete _ownerCandidate; } function rejectTransferOwnership() public virtual { require(_ownerCandidate == _msgSender(), "Ownable: not owner candidate"); delete _ownerCandidate; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Sets the owner. */ function _setOwner(address _newOwner) internal { address oldOwner = _owner; _owner = _newOwner; emit OwnershipTransferred(oldOwner, _newOwner); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.19; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; import {Pausable} from "@openzeppelin/contracts/security/Pausable.sol"; import "./NFTfiToken.sol"; import "./DistributorTokenLock.sol"; import "./utils/Ownable.sol"; /** * @title MerkleDistributor * @author NFTfi * @dev Modified version of Uniswap's MerkleDistributor * https://github.com/Uniswap/merkle-distributor/blob/master/contracts/MerkleDistributor.sol * Main difference: in claim instead of transferring the tokens to the user, * we transfer it to the tokenLock contract */ contract MerkleDistributor is Ownable, Pausable { NFTfiToken public immutable nftfiToken; DistributorTokenLock public immutable distributorTokenLock; address public immutable distributorRegistry; uint256 public immutable claimCutoffDate; bytes32 public merkleRoot; mapping(uint256 => uint256) private claimedBitMap; event Claimed(uint256 _index, uint256 _amount, bytes32[] _merkleProof, address indexed _account); /** * @dev Constructor initializes references for NFTfi token and TokenLock contract. * It also sets the owner of the contract. * @param _admin The initial owner of the contract, usually able to set Merkle roots. * @param _nftfiToken Address of the NFTfi token contract. * @param _distributorTokenLock Address of the TokenLock contract where tokens are transferred upon claims. */ constructor( bytes32 _merkleRoot, address _admin, address _nftfiToken, address _distributorTokenLock, address _distributorRegistry, uint256 _claimCutoffDate ) Ownable(_admin) { merkleRoot = _merkleRoot; nftfiToken = NFTfiToken(_nftfiToken); distributorTokenLock = DistributorTokenLock(_distributorTokenLock); distributorRegistry = _distributorRegistry; claimCutoffDate = _claimCutoffDate; } function isClaimed(uint256 _index) public view returns (bool) { uint256 claimedWordIndex = _index / 256; uint256 claimedBitIndex = _index % 256; uint256 claimedWord = claimedBitMap[claimedWordIndex]; uint256 mask = (1 << claimedBitIndex); return claimedWord & mask == mask; } function _setClaimed(uint256 _index) private { uint256 claimedWordIndex = _index / 256; uint256 claimedBitIndex = _index % 256; claimedBitMap[claimedWordIndex] = claimedBitMap[claimedWordIndex] | (1 << claimedBitIndex); } function claim(uint256 _index, uint256 _amount, bytes32[] memory _merkleProof) external { _claim(_index, _amount, _merkleProof, msg.sender); } function claimFromRegistry( uint256 _index, uint256 _amount, bytes32[] memory _merkleProof, address _claimer ) external { require(msg.sender == distributorRegistry, "Only registry"); _claim(_index, _amount, _merkleProof, _claimer); } function _claim( uint256 _index, uint256 _amount, bytes32[] memory _merkleProof, address _claimer ) internal whenNotPaused { require(block.timestamp < claimCutoffDate, "cutoff date elapsed"); require(!isClaimed(_index), "distributor: already claimed"); // Verify the merkle proof. bytes32 node = keccak256(abi.encodePacked(_index, _claimer, _amount)); require(MerkleProof.verify(_merkleProof, merkleRoot, node), "distributor: invalid proof"); // Mark it claimed and send the token. _setClaimed(_index); nftfiToken.approve(address(distributorTokenLock), _amount); distributorTokenLock.lockTokens(_amount, _claimer); emit Claimed(_index, _amount, _merkleProof, _claimer); } /** * @dev Drain to admin address in an emergency * @param _amount of tokens to drain */ function drain(uint256 _amount) public onlyOwner { nftfiToken.transfer(owner(), _amount); } /** * @dev Triggers stopped state. * * Requirements: * * - Only the owner can call this method. * - The contract must not be paused. */ function pause() external onlyOwner { _pause(); } /** * @dev Returns to normal state. * * Requirements: * * - Only the owner can call this method. * - The contract must be paused. */ function unpause() external onlyOwner { _unpause(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol) 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; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 amount) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.2) (utils/cryptography/MerkleProof.sol) pragma solidity ^0.8.0; /** * @dev These functions deal with verification of Merkle Tree proofs. * * The tree and the proofs can be generated using our * https://github.com/OpenZeppelin/merkle-tree[JavaScript library]. * You will find a quickstart guide in the readme. * * WARNING: You should avoid using leaf values that are 64 bytes long prior to * hashing, or use a hash function other than keccak256 for hashing leaves. * This is because the concatenation of a sorted pair of internal nodes in * the merkle tree could be reinterpreted as a leaf value. * OpenZeppelin's JavaScript library generates merkle trees that are safe * against this attack out of the box. */ library MerkleProof { /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) { return processProof(proof, leaf) == root; } /** * @dev Calldata version of {verify} * * _Available since v4.7._ */ function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) internal pure returns (bool) { return processProofCalldata(proof, leaf) == root; } /** * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt * hash matches the root of the tree. When processing the proof, the pairs * of leafs & pre-images are assumed to be sorted. * * _Available since v4.4._ */ function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { computedHash = _hashPair(computedHash, proof[i]); } return computedHash; } /** * @dev Calldata version of {processProof} * * _Available since v4.7._ */ function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { computedHash = _hashPair(computedHash, proof[i]); } return computedHash; } /** * @dev Returns true if the `leaves` can be simultaneously proven to be a part of a merkle tree defined by * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}. * * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details. * * _Available since v4.7._ */ function multiProofVerify( bytes32[] memory proof, bool[] memory proofFlags, bytes32 root, bytes32[] memory leaves ) internal pure returns (bool) { return processMultiProof(proof, proofFlags, leaves) == root; } /** * @dev Calldata version of {multiProofVerify} * * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details. * * _Available since v4.7._ */ function multiProofVerifyCalldata( bytes32[] calldata proof, bool[] calldata proofFlags, bytes32 root, bytes32[] memory leaves ) internal pure returns (bool) { return processMultiProofCalldata(proof, proofFlags, leaves) == root; } /** * @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction * proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another * leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false * respectively. * * CAUTION: Not all merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree * is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the * tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer). * * _Available since v4.7._ */ function processMultiProof( bytes32[] memory proof, bool[] memory proofFlags, bytes32[] memory leaves ) internal pure returns (bytes32 merkleRoot) { // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of // the merkle tree. uint256 leavesLen = leaves.length; uint256 proofLen = proof.length; uint256 totalHashes = proofFlags.length; // Check proof validity. require(leavesLen + proofLen - 1 == totalHashes, "MerkleProof: invalid multiproof"); // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop". bytes32[] memory hashes = new bytes32[](totalHashes); uint256 leafPos = 0; uint256 hashPos = 0; uint256 proofPos = 0; // At each step, we compute the next hash using two values: // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we // get the next hash. // - depending on the flag, either another value from the "main queue" (merging branches) or an element from the // `proof` array. for (uint256 i = 0; i < totalHashes; i++) { bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]; bytes32 b = proofFlags[i] ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]) : proof[proofPos++]; hashes[i] = _hashPair(a, b); } if (totalHashes > 0) { require(proofPos == proofLen, "MerkleProof: invalid multiproof"); unchecked { return hashes[totalHashes - 1]; } } else if (leavesLen > 0) { return leaves[0]; } else { return proof[0]; } } /** * @dev Calldata version of {processMultiProof}. * * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details. * * _Available since v4.7._ */ function processMultiProofCalldata( bytes32[] calldata proof, bool[] calldata proofFlags, bytes32[] memory leaves ) internal pure returns (bytes32 merkleRoot) { // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of // the merkle tree. uint256 leavesLen = leaves.length; uint256 proofLen = proof.length; uint256 totalHashes = proofFlags.length; // Check proof validity. require(leavesLen + proofLen - 1 == totalHashes, "MerkleProof: invalid multiproof"); // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop". bytes32[] memory hashes = new bytes32[](totalHashes); uint256 leafPos = 0; uint256 hashPos = 0; uint256 proofPos = 0; // At each step, we compute the next hash using two values: // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we // get the next hash. // - depending on the flag, either another value from the "main queue" (merging branches) or an element from the // `proof` array. for (uint256 i = 0; i < totalHashes; i++) { bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]; bytes32 b = proofFlags[i] ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]) : proof[proofPos++]; hashes[i] = _hashPair(a, b); } if (totalHashes > 0) { require(proofPos == proofLen, "MerkleProof: invalid multiproof"); unchecked { return hashes[totalHashes - 1]; } } else if (leavesLen > 0) { return leaves[0]; } else { return proof[0]; } } function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) { return a < b ? _efficientHash(a, b) : _efficientHash(b, a); } function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) { /// @solidity memory-safe-assembly assembly { mstore(0x00, a) mstore(0x20, b) value := keccak256(0x00, 0x40) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol) 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 Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { require(!paused(), "Pausable: paused"); } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { 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.19; import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol"; string constant NAME = "NFTfi"; string constant SYMBOL = "NFTFI"; /** * @title NFTfiToken * @author NFTfi * @dev standard ERC20 token */ contract NFTfiToken is ERC20Permit { constructor(uint256 _initialSupply, address _owner) ERC20(NAME, SYMBOL) ERC20Permit(NAME) { _mint(_owner, _initialSupply); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/ERC20Permit.sol) pragma solidity ^0.8.0; import "./IERC20Permit.sol"; import "../ERC20.sol"; import "../../../utils/cryptography/ECDSA.sol"; import "../../../utils/cryptography/EIP712.sol"; import "../../../utils/Counters.sol"; /** * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * _Available since v3.4._ */ abstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 { using Counters for Counters.Counter; mapping(address => Counters.Counter) private _nonces; // solhint-disable-next-line var-name-mixedcase bytes32 private constant _PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); /** * @dev In previous versions `_PERMIT_TYPEHASH` was declared as `immutable`. * However, to ensure consistency with the upgradeable transpiler, we will continue * to reserve a slot. * @custom:oz-renamed-from _PERMIT_TYPEHASH */ // solhint-disable-next-line var-name-mixedcase bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT; /** * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`. * * It's a good idea to use the same `name` that is defined as the ERC20 token name. */ constructor(string memory name) EIP712(name, "1") {} /** * @inheritdoc IERC20Permit */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual override { require(block.timestamp <= deadline, "ERC20Permit: expired deadline"); bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline)); bytes32 hash = _hashTypedDataV4(structHash); address signer = ECDSA.recover(hash, v, r, s); require(signer == owner, "ERC20Permit: invalid signature"); _approve(owner, spender, value); } /** * @inheritdoc IERC20Permit */ function nonces(address owner) public view virtual override returns (uint256) { return _nonces[owner].current(); } /** * @inheritdoc IERC20Permit */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view override returns (bytes32) { return _domainSeparatorV4(); } /** * @dev "Consume a nonce": return the current value and increment. * * _Available since v4.1._ */ function _useNonce(address owner) internal virtual returns (uint256 current) { Counters.Counter storage nonce = _nonces[owner]; current = nonce.current(); nonce.increment(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * ==== Security Considerations * * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be * considered as an intention to spend the allowance in any specific way. The second is that because permits have * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be * generally recommended is: * * ```solidity * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public { * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {} * doThing(..., value); * } * * function doThing(..., uint256 value) public { * token.safeTransferFrom(msg.sender, address(this), value); * ... * } * ``` * * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also * {SafeERC20-safeTransferFrom}). * * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so * contracts should have entry points that don't rely on permit. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. * * CAUTION: See Security Considerations above. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol) 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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * The default value of {decimals} is 18. To change this, you should override * this function so it returns a different value. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract 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}. * * 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 default value returned by this function, unless * it's overridden. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address to, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, allowance(owner, spender) + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { address owner = _msgSender(); uint256 currentAllowance = allowance(owner, spender); require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(owner, spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `from` to `to`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. */ function _transfer(address from, address to, uint256 amount) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(from, to, amount); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by // decrementing then incrementing. _balances[to] += amount; } emit Transfer(from, to, amount); _afterTokenTransfer(from, to, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; unchecked { // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above. _balances[account] += amount; } emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; // Overflow not possible: amount <= accountBalance <= totalSupply. _totalSupply -= amount; } emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Updates `owner` s allowance for `spender` based on spent `amount`. * * Does not update the allowance amount in case of infinite allowance. * Revert if not enough allowance is available. * * Might emit an {Approval} event. */ function _spendAllowance(address owner, address spender, uint256 amount) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.0; import "../Strings.sol"; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV // Deprecated in v4.8 } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. /// @solidity memory-safe-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError) { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 message) { // 32 is the length in bytes of hash, // enforced by the type signature above /// @solidity memory-safe-assembly assembly { mstore(0x00, "\x19Ethereum Signed Message:\n32") mstore(0x1c, hash) message := keccak256(0x00, 0x3c) } } /** * @dev Returns an Ethereum Signed Message, created from `s`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 data) { /// @solidity memory-safe-assembly assembly { let ptr := mload(0x40) mstore(ptr, "\x19\x01") mstore(add(ptr, 0x02), domainSeparator) mstore(add(ptr, 0x22), structHash) data := keccak256(ptr, 0x42) } } /** * @dev Returns an Ethereum Signed Data with intended validator, created from a * `validator` and `data` according to the version 0 of EIP-191. * * See {recover}. */ function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x00", validator, data)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/EIP712.sol) pragma solidity ^0.8.8; import "./ECDSA.sol"; import "../ShortStrings.sol"; import "../../interfaces/IERC5267.sol"; /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible, * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding * they need in their contracts using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain * separator of the implementation contract. This will cause the `_domainSeparatorV4` function to always rebuild the * separator from the immutable values, which is cheaper than accessing a cached version in cold storage. * * _Available since v3.4._ * * @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment */ abstract contract EIP712 is IERC5267 { using ShortStrings for *; bytes32 private constant _TYPE_HASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"); // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to // invalidate the cached domain separator if the chain id changes. bytes32 private immutable _cachedDomainSeparator; uint256 private immutable _cachedChainId; address private immutable _cachedThis; bytes32 private immutable _hashedName; bytes32 private immutable _hashedVersion; ShortString private immutable _name; ShortString private immutable _version; string private _nameFallback; string private _versionFallback; /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ constructor(string memory name, string memory version) { _name = name.toShortStringWithFallback(_nameFallback); _version = version.toShortStringWithFallback(_versionFallback); _hashedName = keccak256(bytes(name)); _hashedVersion = keccak256(bytes(version)); _cachedChainId = block.chainid; _cachedDomainSeparator = _buildDomainSeparator(); _cachedThis = address(this); } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view returns (bytes32) { if (address(this) == _cachedThis && block.chainid == _cachedChainId) { return _cachedDomainSeparator; } else { return _buildDomainSeparator(); } } function _buildDomainSeparator() private view returns (bytes32) { return keccak256(abi.encode(_TYPE_HASH, _hashedName, _hashedVersion, block.chainid, address(this))); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash); } /** * @dev See {EIP-5267}. * * _Available since v4.9._ */ function eip712Domain() public view virtual override returns ( bytes1 fields, string memory name, string memory version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] memory extensions ) { return ( hex"0f", // 01111 _name.toStringWithFallback(_nameFallback), _version.toStringWithFallback(_versionFallback), block.chainid, address(this), bytes32(0), new uint256[](0) ); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) 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 // OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/Math.sol"; import "./math/SignedMath.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `int256` to its ASCII `string` decimal representation. */ function toString(int256 value) internal pure returns (string memory) { return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value)))); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @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] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } /** * @dev Returns true if the two strings are equal. */ function equal(string memory a, string memory b) internal pure returns (bool) { return keccak256(bytes(a)) == keccak256(bytes(b)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1, "Math: mulDiv overflow"); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.0; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMath { /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return a > b ? a : b; } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return a < b ? a : b; } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // must be unchecked in order to support `n = type(int256).min` return uint256(n >= 0 ? n : -n); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/ShortStrings.sol) pragma solidity ^0.8.8; import "./StorageSlot.sol"; // | string | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA | // | length | 0x BB | type ShortString is bytes32; /** * @dev This library provides functions to convert short memory strings * into a `ShortString` type that can be used as an immutable variable. * * Strings of arbitrary length can be optimized using this library if * they are short enough (up to 31 bytes) by packing them with their * length (1 byte) in a single EVM word (32 bytes). Additionally, a * fallback mechanism can be used for every other case. * * Usage example: * * ```solidity * contract Named { * using ShortStrings for *; * * ShortString private immutable _name; * string private _nameFallback; * * constructor(string memory contractName) { * _name = contractName.toShortStringWithFallback(_nameFallback); * } * * function name() external view returns (string memory) { * return _name.toStringWithFallback(_nameFallback); * } * } * ``` */ library ShortStrings { // Used as an identifier for strings longer than 31 bytes. bytes32 private constant _FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF; error StringTooLong(string str); error InvalidShortString(); /** * @dev Encode a string of at most 31 chars into a `ShortString`. * * This will trigger a `StringTooLong` error is the input string is too long. */ function toShortString(string memory str) internal pure returns (ShortString) { bytes memory bstr = bytes(str); if (bstr.length > 31) { revert StringTooLong(str); } return ShortString.wrap(bytes32(uint256(bytes32(bstr)) | bstr.length)); } /** * @dev Decode a `ShortString` back to a "normal" string. */ function toString(ShortString sstr) internal pure returns (string memory) { uint256 len = byteLength(sstr); // using `new string(len)` would work locally but is not memory safe. string memory str = new string(32); /// @solidity memory-safe-assembly assembly { mstore(str, len) mstore(add(str, 0x20), sstr) } return str; } /** * @dev Return the length of a `ShortString`. */ function byteLength(ShortString sstr) internal pure returns (uint256) { uint256 result = uint256(ShortString.unwrap(sstr)) & 0xFF; if (result > 31) { revert InvalidShortString(); } return result; } /** * @dev Encode a string into a `ShortString`, or write it to storage if it is too long. */ function toShortStringWithFallback(string memory value, string storage store) internal returns (ShortString) { if (bytes(value).length < 32) { return toShortString(value); } else { StorageSlot.getStringSlot(store).value = value; return ShortString.wrap(_FALLBACK_SENTINEL); } } /** * @dev Decode a string that was encoded to `ShortString` or written to storage using {setWithFallback}. */ function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory) { if (ShortString.unwrap(value) != _FALLBACK_SENTINEL) { return toString(value); } else { return store; } } /** * @dev Return the length of a string that was encoded to `ShortString` or written to storage using {setWithFallback}. * * WARNING: This will return the "byte length" of the string. This may not reflect the actual length in terms of * actual characters as the UTF-8 encoding of a single character can span over multiple bytes. */ function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) { if (ShortString.unwrap(value) != _FALLBACK_SENTINEL) { return byteLength(value); } else { return bytes(store).length; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC5267.sol) pragma solidity ^0.8.0; interface IERC5267 { /** * @dev MAY be emitted to signal that the domain could have changed. */ event EIP712DomainChanged(); /** * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712 * signature. */ function eip712Domain() external view returns ( bytes1 fields, string memory name, string memory version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] memory extensions ); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/StorageSlot.sol) // This file was procedurally generated from scripts/generate/templates/StorageSlot.js. pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ```solidity * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, `uint256`._ * _Available since v4.9 for `string`, `bytes`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } struct StringSlot { string value; } struct BytesSlot { bytes value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `StringSlot` with member `value` located at `slot`. */ function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `StringSlot` representation of the string storage pointer `store`. */ function getStringSlot(string storage store) internal pure returns (StringSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } /** * @dev Returns an `BytesSlot` with member `value` located at `slot`. */ function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`. */ function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../extensions/IERC20Permit.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; /** * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } /** * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful. */ 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)); } /** * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value)); } /** * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ 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"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value)); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval * to be set to zero before setting it to a non-zero value, such as USDT. */ function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0)); _callOptionalReturn(token, approvalCall); } } /** * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`. * Revert on invalid signature. */ function safePermit( IERC20Permit token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). * * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) { // 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 cannot use {Address-functionCall} here since this should return false // and not revert is the subcall reverts. (bool success, bytes memory returndata) = address(token).call(data); return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library 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 * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/SignatureChecker.sol) pragma solidity ^0.8.0; import "./ECDSA.sol"; import "../../interfaces/IERC1271.sol"; /** * @dev Signature verification helper that can be used instead of `ECDSA.recover` to seamlessly support both ECDSA * signatures from externally owned accounts (EOAs) as well as ERC1271 signatures from smart contract wallets like * Argent and Gnosis Safe. * * _Available since v4.1._ */ library SignatureChecker { /** * @dev Checks if a signature is valid for a given signer and data hash. If the signer is a smart contract, the * signature is validated against that smart contract using ERC1271, otherwise it's validated using `ECDSA.recover`. * * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus * change through time. It could return true at block N and false at block N+1 (or the opposite). */ function isValidSignatureNow(address signer, bytes32 hash, bytes memory signature) internal view returns (bool) { (address recovered, ECDSA.RecoverError error) = ECDSA.tryRecover(hash, signature); return (error == ECDSA.RecoverError.NoError && recovered == signer) || isValidERC1271SignatureNow(signer, hash, signature); } /** * @dev Checks if a signature is valid for a given signer and data hash. The signature is validated * against the signer smart contract using ERC1271. * * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus * change through time. It could return true at block N and false at block N+1 (or the opposite). */ function isValidERC1271SignatureNow( address signer, bytes32 hash, bytes memory signature ) internal view returns (bool) { (bool success, bytes memory result) = signer.staticcall( abi.encodeWithSelector(IERC1271.isValidSignature.selector, hash, signature) ); return (success && result.length >= 32 && abi.decode(result, (bytes32)) == bytes32(IERC1271.isValidSignature.selector)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC1271.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC1271 standard signature validation method for * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271]. * * _Available since v4.1._ */ interface IERC1271 { /** * @dev Should return whether the signature provided is valid for the provided data * @param hash Hash of the data to be signed * @param signature Signature byte array associated with _data */ function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue); }
{ "metadata": { "bytecodeHash": "none", "useLiteralContent": true }, "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_admin","type":"address"},{"internalType":"address","name":"_nftfi","type":"address"},{"internalType":"address","name":"_distributorRegistry","type":"address"},{"internalType":"address","name":"_tokenUtilityAccounting","type":"address"},{"internalType":"address","name":"_protocolSignerAddress","type":"address"},{"internalType":"uint256","name":"_cooldown","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"_user","type":"address"}],"name":"Locked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":false,"internalType":"uint256","name":"_timestamp","type":"uint256"}],"name":"WithdrawalRequestDeleted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":false,"internalType":"uint256","name":"_timestamp","type":"uint256"}],"name":"WithdrawalRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"_user","type":"address"}],"name":"Withdrawn","type":"event"},{"inputs":[],"name":"acceptTransferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"cancelTransferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"cooldown","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"distributorRegistry","outputs":[{"internalType":"contract DistributorRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_beneficiary","type":"address"}],"name":"lockTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lockedTokens","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nftfiToken","outputs":[{"internalType":"contract NFTfiToken","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"protocolSignerAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rejectTransferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwnerCandidate","type":"address"}],"name":"requestTransferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_cooldown","type":"uint256"}],"name":"setCooldown","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_protocolSignerAddress","type":"address"}],"name":"setProtocolSignerAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newTokenUtilityAccounting","type":"address"}],"name":"setTokenUtilityAccounting","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"tokenUtilityAccounting","outputs":[{"internalType":"contract TokenUtilityAccounting","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_requestTimestamp","type":"uint256"},{"internalType":"uint256","name":"_protocolSignatureExpiry","type":"uint256"},{"internalType":"bytes","name":"_protocolSignature","type":"bytes"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_amounts","type":"uint256[]"},{"internalType":"uint256[]","name":"_requestTimestamps","type":"uint256[]"},{"internalType":"uint256[]","name":"_protocolSignatureExpiries","type":"uint256[]"},{"internalType":"bytes[]","name":"_protocolSignatures","type":"bytes[]"}],"name":"withdrawMultiple","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"withdrawRequests","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"withdrawalRequestAmounts","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
60c06040523480156200001157600080fd5b5060405162001d7938038062001d7983398101604081905262000034916200010b565b858584838362000044816200009e565b506001805460ff60a01b191690556001600160a01b03928316608052600280549284166001600160a01b031993841617905560035595811660a0526007805494909116939095169290921790935550620001839350505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80516001600160a01b03811681146200010657600080fd5b919050565b60008060008060008060c087890312156200012557600080fd5b6200013087620000ee565b95506200014060208801620000ee565b94506200015060408801620000ee565b93506200016060608801620000ee565b92506200017060808801620000ee565b915060a087015190509295509295509295565b60805160a051611bbb620001be600039600081816101d701526107b901526000818161014b01528181610b5f0152610fec0152611bbb6000f3fe608060405234801561001057600080fd5b50600436106101415760003560e01c8063787a08a6116100b85780638f9bb71d1161007c5780638f9bb71d146102cc57806392fede00146102df5780639d6fa618146102e7578063aa68acde146102fa578063e61b16a81461030d578063fe55892d1461032057600080fd5b8063787a08a61461028f5780637b3711071461029857806380014748146102a05780638456cb59146102b35780638da5cb5b146102bb57600080fd5b80634134fa5f1161010a5780634134fa5f146102015780634fc3f41a146102145780635c975abb146102275780635eb7413a146102395780635f992fdd146102675780637215774a1461026f57600080fd5b80627fc3f214610146578063026508d11461018a5780631788d6b2146101bd5780632daa7555146101d25780633f4ba83a146101f9575b600080fd5b61016d7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b6101ad6101983660046117bf565b60066020526000908152604090205460ff1681565b6040519015158152602001610181565b6101d06101cb3660046117f4565b610333565b005b61016d7f000000000000000000000000000000000000000000000000000000000000000081565b6101d0610388565b60025461016d906001600160a01b031681565b6101d06102223660046117bf565b6103bc565b600154600160a01b900460ff166101ad565b6102596102473660046117f4565b60046020526000908152604090205481565b604051908152602001610181565b6101d06103eb565b61025961027d3660046117f4565b60056020526000908152604090205481565b61025960035481565b6101d0610457565b6101d06102ae36600461185b565b6104c6565b6101d061064b565b6000546001600160a01b031661016d565b6101d06102da3660046117f4565b61067d565b6101d06106c9565b6101d06102f53660046117f4565b6106f3565b6101d061030836600461191f565b6107a4565b60075461016d906001600160a01b031681565b6101d061032e36600461194b565b610890565b6000546001600160a01b031633146103665760405162461bcd60e51b815260040161035d906119d8565b60405180910390fd5b600280546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031633146103b25760405162461bcd60e51b815260040161035d906119d8565b6103ba6109cf565b565b6000546001600160a01b031633146103e65760405162461bcd60e51b815260040161035d906119d8565b600355565b6001546001600160a01b031633146104455760405162461bcd60e51b815260206004820152601c60248201527f4f776e61626c653a206e6f74206f776e65722063616e64696461746500000000604482015260640161035d565b600180546001600160a01b0319169055565b6001546001600160a01b031633146104b15760405162461bcd60e51b815260206004820152601c60248201527f4f776e61626c653a206e6f74206f776e65722063616e64696461746500000000604482015260640161035d565b600154610445906001600160a01b0316610a24565b8685146105155760405162461bcd60e51b815260206004820152601860248201527f706172616d65746572206172697479206d69736d617463680000000000000000604482015260640161035d565b8685146105645760405162461bcd60e51b815260206004820152601a60248201527f706172616d65746572206172697479206d69736d617463682032000000000000604482015260640161035d565b8685146105b35760405162461bcd60e51b815260206004820152601a60248201527f706172616d65746572206172697479206d69736d617463682033000000000000604482015260640161035d565b60005b87811015610640576106308989838181106105d3576105d3611a0d565b905060200201358888848181106105ec576105ec611a0d565b9050602002013587878581811061060557610605611a0d565b9050602002013586868681811061061e5761061e611a0d565b905060200281019061032e9190611a23565b61063981611a80565b90506105b6565b505050505050505050565b6000546001600160a01b031633146106755760405162461bcd60e51b815260040161035d906119d8565b6103ba610a74565b6000546001600160a01b031633146106a75760405162461bcd60e51b815260040161035d906119d8565b600780546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031633146104455760405162461bcd60e51b815260040161035d906119d8565b6000546001600160a01b0316331461071d5760405162461bcd60e51b815260040161035d906119d8565b6001600160a01b0381166107825760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161035d565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b604051634786437d60e11b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690638f0c86fa90602401602060405180830381865afa158015610808573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061082c9190611a99565b6108785760405162461bcd60e51b815260206004820152601b60248201527f4f6e6c792072656769737465726564206469737472696275746f720000000000604482015260640161035d565b6108828282610ab7565b61088c8282610bd0565b5050565b6007546001600160a01b031615610965576109193386866040518060600160405280888152602001600760009054906101000a90046001600160a01b03166001600160a01b0316815260200187878080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050915250610d51565b6109655760405162461bcd60e51b815260206004820152601a60248201527f50726f746f636f6c207369676e617475726520696e76616c6964000000000000604482015260640161035d565b61096f8585610e5e565b600254604051637eee288d60e01b8152336004820152602481018790526001600160a01b0390911690637eee288d90604401600060405180830381600087803b1580156109bb57600080fd5b505af1158015610640573d6000803e3d6000fd5b6109d7611045565b6001805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b610a7c611095565b6001805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258610a073390565b610abf611095565b6001600160a01b03811660009081526004602052604081208054849290610ae7908490611abb565b909155505060025460405163282d3fdf60e01b81526001600160a01b038381166004830152602482018590529091169063282d3fdf90604401600060405180830381600087803b158015610b3a57600080fd5b505af1158015610b4e573d6000803e3d6000fd5b50610b899250506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690503330856110e2565b806001600160a01b03167f748bbc70c40b2e3e3b828688a7a7d8c2afb1e06ebe33406a029f4e985f94e07a83604051610bc491815260200190565b60405180910390a25050565b610bd8611095565b6001600160a01b038116600090815260046020908152604080832054600590925290912054610c079084611abb565b1115610c555760405162461bcd60e51b815260206004820152601760248201527f7265717565737420616d6f756e7473203e20746f74616c000000000000000000604482015260640161035d565b6000610c62838342611153565b60008181526006602052604090205490915060ff1615610cb85760405162461bcd60e51b8152602060048201526011602482015270191d5c1b1a58d85d19481c995c5d595cdd607a1b604482015260640161035d565b6001600160a01b03821660009081526005602052604081208054859290610ce0908490611abb565b909155505060008181526006602052604090819020805460ff19166001179055516001600160a01b038316907f6620e1bb18901e7cc06eb4c152cbf61f7f069350e9cf118060d463c4e5430ba090610d449086904290918252602082015260400190565b60405180910390a2505050565b8051600090421115610da55760405162461bcd60e51b815260206004820152601a60248201527f50726f746f636f6c205369676e61747572652065787069726564000000000000604482015260640161035d565b60208281015183516040516bffffffffffffffffffffffff1960608a811b82169583019590955260348201899052605482018890529290931b9091166074830152608882015260009060a801604051602081830303815290604052805190602001209050610e528360200151610e48837f19457468657265756d205369676e6564204d6573736167653a0a3332000000006000908152601c91909152603c902090565b856040015161119c565b9150505b949350505050565b610e66611095565b33600090815260046020526040902054821115610ec55760405162461bcd60e51b815260206004820152601760248201527f776974686472617720616d6f756e74203e20746f74616c000000000000000000604482015260640161035d565b60035415610f2657600354610eda9082611abb565b421015610f1b5760405162461bcd60e51b815260206004820152600f60248201526e0636f6f6c646f776e206e6f7420757608c1b604482015260640161035d565b610f268233836111fd565b600354600003610fba573360009081526005602052604090205415610f5557610f508233836111fd565b610fba565b600254604051637eee288d60e01b8152336004820152602481018490526001600160a01b0390911690637eee288d90604401600060405180830381600087803b158015610fa157600080fd5b505af1158015610fb5573d6000803e3d6000fd5b505050505b3360009081526004602052604081208054849290610fd9908490611ad4565b9091555061101390506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163384611338565b60405182815233907f8c7cdad0d12a8db3e23561b42da6f10c8137914c97beff202213a410e1f520a390602001610bc4565b600154600160a01b900460ff166103ba5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015260640161035d565b600154600160a01b900460ff16156103ba5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015260640161035d565b6040516001600160a01b038085166024830152831660448201526064810182905261114d9085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261136d565b50505050565b6040805160208082019590955260609390931b6bffffffffffffffffffffffff191683820152605480840192909252805180840390920182526074909201909152805191012090565b60008060006111ab8585611442565b909250905060008160048111156111c4576111c4611ae7565b1480156111e25750856001600160a01b0316826001600160a01b0316145b806111f357506111f3868686611487565b9695505050505050565b611205611095565b6000611212848484611153565b60008181526006602052604090205490915060ff166112605760405162461bcd60e51b815260206004820152600a6024820152691b9bc81c995c5d595cdd60b21b604482015260640161035d565b336000908152600560205260409020548411156112bf5760405162461bcd60e51b815260206004820152601760248201527f616d6f756e74203e2072657175657374416d6f756e7473000000000000000000604482015260640161035d565b6000818152600660209081526040808320805460ff191690553383526005909152812080548692906112f2908490611ad4565b9091555050604080518581526020810184905233917f8beac21ec0206d8057c3ea48edd216fd5e5346e0cdedf004fe19773ebed39d62910160405180910390a250505050565b6040516001600160a01b03831660248201526044810182905261136890849063a9059cbb60e01b90606401611116565b505050565b60006113c2826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166115739092919063ffffffff16565b90508051600014806113e35750808060200190518101906113e39190611a99565b6113685760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161035d565b60008082516041036114785760208301516040840151606085015160001a61146c87828585611582565b94509450505050611480565b506000905060025b9250929050565b6000806000856001600160a01b0316631626ba7e60e01b86866040516024016114b1929190611b4d565b60408051601f198184030181529181526020820180516001600160e01b03166001600160e01b03199094169390931790925290516114ef9190611b66565b600060405180830381855afa9150503d806000811461152a576040519150601f19603f3d011682016040523d82523d6000602084013e61152f565b606091505b509150915081801561154357506020815110155b80156111f357508051630b135d3f60e11b906115689083016020908101908401611b82565b149695505050505050565b6060610e568484600085611646565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156115b9575060009050600361163d565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa15801561160d573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166116365760006001925092505061163d565b9150600090505b94509492505050565b6060824710156116a75760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161035d565b600080866001600160a01b031685876040516116c39190611b66565b60006040518083038185875af1925050503d8060008114611700576040519150601f19603f3d011682016040523d82523d6000602084013e611705565b606091505b509150915061171687838387611721565b979650505050505050565b60608315611790578251600003611789576001600160a01b0385163b6117895760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161035d565b5081610e56565b610e5683838151156117a55781518083602001fd5b8060405162461bcd60e51b815260040161035d9190611b9b565b6000602082840312156117d157600080fd5b5035919050565b80356001600160a01b03811681146117ef57600080fd5b919050565b60006020828403121561180657600080fd5b61180f826117d8565b9392505050565b60008083601f84011261182857600080fd5b50813567ffffffffffffffff81111561184057600080fd5b6020830191508360208260051b850101111561148057600080fd5b6000806000806000806000806080898b03121561187757600080fd5b883567ffffffffffffffff8082111561188f57600080fd5b61189b8c838d01611816565b909a50985060208b01359150808211156118b457600080fd5b6118c08c838d01611816565b909850965060408b01359150808211156118d957600080fd5b6118e58c838d01611816565b909650945060608b01359150808211156118fe57600080fd5b5061190b8b828c01611816565b999c989b5096995094979396929594505050565b6000806040838503121561193257600080fd5b82359150611942602084016117d8565b90509250929050565b60008060008060006080868803121561196357600080fd5b853594506020860135935060408601359250606086013567ffffffffffffffff8082111561199057600080fd5b818801915088601f8301126119a457600080fd5b8135818111156119b357600080fd5b8960208285010111156119c557600080fd5b9699959850939650602001949392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052603260045260246000fd5b6000808335601e19843603018112611a3a57600080fd5b83018035915067ffffffffffffffff821115611a5557600080fd5b60200191503681900382131561148057600080fd5b634e487b7160e01b600052601160045260246000fd5b600060018201611a9257611a92611a6a565b5060010190565b600060208284031215611aab57600080fd5b8151801515811461180f57600080fd5b80820180821115611ace57611ace611a6a565b92915050565b81810381811115611ace57611ace611a6a565b634e487b7160e01b600052602160045260246000fd5b60005b83811015611b18578181015183820152602001611b00565b50506000910152565b60008151808452611b39816020860160208601611afd565b601f01601f19169290920160200192915050565b828152604060208201526000610e566040830184611b21565b60008251611b78818460208701611afd565b9190910192915050565b600060208284031215611b9457600080fd5b5051919050565b60208152600061180f6020830184611b2156fea164736f6c6343000813000a000000000000000000000000aef67478a5595fc220d43338b8674dc50c6de54f00000000000000000000000009d6f0f5a21f5be4f59e209747e2d07f50bc694c000000000000000000000000bf72e7c502bf088b0ff674c67d569da1304faab80000000000000000000000005ea4de24d668085d37c423e1d4eef5acc76daaaa0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000034bc00
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106101415760003560e01c8063787a08a6116100b85780638f9bb71d1161007c5780638f9bb71d146102cc57806392fede00146102df5780639d6fa618146102e7578063aa68acde146102fa578063e61b16a81461030d578063fe55892d1461032057600080fd5b8063787a08a61461028f5780637b3711071461029857806380014748146102a05780638456cb59146102b35780638da5cb5b146102bb57600080fd5b80634134fa5f1161010a5780634134fa5f146102015780634fc3f41a146102145780635c975abb146102275780635eb7413a146102395780635f992fdd146102675780637215774a1461026f57600080fd5b80627fc3f214610146578063026508d11461018a5780631788d6b2146101bd5780632daa7555146101d25780633f4ba83a146101f9575b600080fd5b61016d7f00000000000000000000000009d6f0f5a21f5be4f59e209747e2d07f50bc694c81565b6040516001600160a01b0390911681526020015b60405180910390f35b6101ad6101983660046117bf565b60066020526000908152604090205460ff1681565b6040519015158152602001610181565b6101d06101cb3660046117f4565b610333565b005b61016d7f000000000000000000000000bf72e7c502bf088b0ff674c67d569da1304faab881565b6101d0610388565b60025461016d906001600160a01b031681565b6101d06102223660046117bf565b6103bc565b600154600160a01b900460ff166101ad565b6102596102473660046117f4565b60046020526000908152604090205481565b604051908152602001610181565b6101d06103eb565b61025961027d3660046117f4565b60056020526000908152604090205481565b61025960035481565b6101d0610457565b6101d06102ae36600461185b565b6104c6565b6101d061064b565b6000546001600160a01b031661016d565b6101d06102da3660046117f4565b61067d565b6101d06106c9565b6101d06102f53660046117f4565b6106f3565b6101d061030836600461191f565b6107a4565b60075461016d906001600160a01b031681565b6101d061032e36600461194b565b610890565b6000546001600160a01b031633146103665760405162461bcd60e51b815260040161035d906119d8565b60405180910390fd5b600280546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031633146103b25760405162461bcd60e51b815260040161035d906119d8565b6103ba6109cf565b565b6000546001600160a01b031633146103e65760405162461bcd60e51b815260040161035d906119d8565b600355565b6001546001600160a01b031633146104455760405162461bcd60e51b815260206004820152601c60248201527f4f776e61626c653a206e6f74206f776e65722063616e64696461746500000000604482015260640161035d565b600180546001600160a01b0319169055565b6001546001600160a01b031633146104b15760405162461bcd60e51b815260206004820152601c60248201527f4f776e61626c653a206e6f74206f776e65722063616e64696461746500000000604482015260640161035d565b600154610445906001600160a01b0316610a24565b8685146105155760405162461bcd60e51b815260206004820152601860248201527f706172616d65746572206172697479206d69736d617463680000000000000000604482015260640161035d565b8685146105645760405162461bcd60e51b815260206004820152601a60248201527f706172616d65746572206172697479206d69736d617463682032000000000000604482015260640161035d565b8685146105b35760405162461bcd60e51b815260206004820152601a60248201527f706172616d65746572206172697479206d69736d617463682033000000000000604482015260640161035d565b60005b87811015610640576106308989838181106105d3576105d3611a0d565b905060200201358888848181106105ec576105ec611a0d565b9050602002013587878581811061060557610605611a0d565b9050602002013586868681811061061e5761061e611a0d565b905060200281019061032e9190611a23565b61063981611a80565b90506105b6565b505050505050505050565b6000546001600160a01b031633146106755760405162461bcd60e51b815260040161035d906119d8565b6103ba610a74565b6000546001600160a01b031633146106a75760405162461bcd60e51b815260040161035d906119d8565b600780546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031633146104455760405162461bcd60e51b815260040161035d906119d8565b6000546001600160a01b0316331461071d5760405162461bcd60e51b815260040161035d906119d8565b6001600160a01b0381166107825760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161035d565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b604051634786437d60e11b81523360048201527f000000000000000000000000bf72e7c502bf088b0ff674c67d569da1304faab86001600160a01b031690638f0c86fa90602401602060405180830381865afa158015610808573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061082c9190611a99565b6108785760405162461bcd60e51b815260206004820152601b60248201527f4f6e6c792072656769737465726564206469737472696275746f720000000000604482015260640161035d565b6108828282610ab7565b61088c8282610bd0565b5050565b6007546001600160a01b031615610965576109193386866040518060600160405280888152602001600760009054906101000a90046001600160a01b03166001600160a01b0316815260200187878080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050915250610d51565b6109655760405162461bcd60e51b815260206004820152601a60248201527f50726f746f636f6c207369676e617475726520696e76616c6964000000000000604482015260640161035d565b61096f8585610e5e565b600254604051637eee288d60e01b8152336004820152602481018790526001600160a01b0390911690637eee288d90604401600060405180830381600087803b1580156109bb57600080fd5b505af1158015610640573d6000803e3d6000fd5b6109d7611045565b6001805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b610a7c611095565b6001805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258610a073390565b610abf611095565b6001600160a01b03811660009081526004602052604081208054849290610ae7908490611abb565b909155505060025460405163282d3fdf60e01b81526001600160a01b038381166004830152602482018590529091169063282d3fdf90604401600060405180830381600087803b158015610b3a57600080fd5b505af1158015610b4e573d6000803e3d6000fd5b50610b899250506001600160a01b037f00000000000000000000000009d6f0f5a21f5be4f59e209747e2d07f50bc694c1690503330856110e2565b806001600160a01b03167f748bbc70c40b2e3e3b828688a7a7d8c2afb1e06ebe33406a029f4e985f94e07a83604051610bc491815260200190565b60405180910390a25050565b610bd8611095565b6001600160a01b038116600090815260046020908152604080832054600590925290912054610c079084611abb565b1115610c555760405162461bcd60e51b815260206004820152601760248201527f7265717565737420616d6f756e7473203e20746f74616c000000000000000000604482015260640161035d565b6000610c62838342611153565b60008181526006602052604090205490915060ff1615610cb85760405162461bcd60e51b8152602060048201526011602482015270191d5c1b1a58d85d19481c995c5d595cdd607a1b604482015260640161035d565b6001600160a01b03821660009081526005602052604081208054859290610ce0908490611abb565b909155505060008181526006602052604090819020805460ff19166001179055516001600160a01b038316907f6620e1bb18901e7cc06eb4c152cbf61f7f069350e9cf118060d463c4e5430ba090610d449086904290918252602082015260400190565b60405180910390a2505050565b8051600090421115610da55760405162461bcd60e51b815260206004820152601a60248201527f50726f746f636f6c205369676e61747572652065787069726564000000000000604482015260640161035d565b60208281015183516040516bffffffffffffffffffffffff1960608a811b82169583019590955260348201899052605482018890529290931b9091166074830152608882015260009060a801604051602081830303815290604052805190602001209050610e528360200151610e48837f19457468657265756d205369676e6564204d6573736167653a0a3332000000006000908152601c91909152603c902090565b856040015161119c565b9150505b949350505050565b610e66611095565b33600090815260046020526040902054821115610ec55760405162461bcd60e51b815260206004820152601760248201527f776974686472617720616d6f756e74203e20746f74616c000000000000000000604482015260640161035d565b60035415610f2657600354610eda9082611abb565b421015610f1b5760405162461bcd60e51b815260206004820152600f60248201526e0636f6f6c646f776e206e6f7420757608c1b604482015260640161035d565b610f268233836111fd565b600354600003610fba573360009081526005602052604090205415610f5557610f508233836111fd565b610fba565b600254604051637eee288d60e01b8152336004820152602481018490526001600160a01b0390911690637eee288d90604401600060405180830381600087803b158015610fa157600080fd5b505af1158015610fb5573d6000803e3d6000fd5b505050505b3360009081526004602052604081208054849290610fd9908490611ad4565b9091555061101390506001600160a01b037f00000000000000000000000009d6f0f5a21f5be4f59e209747e2d07f50bc694c163384611338565b60405182815233907f8c7cdad0d12a8db3e23561b42da6f10c8137914c97beff202213a410e1f520a390602001610bc4565b600154600160a01b900460ff166103ba5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015260640161035d565b600154600160a01b900460ff16156103ba5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015260640161035d565b6040516001600160a01b038085166024830152831660448201526064810182905261114d9085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261136d565b50505050565b6040805160208082019590955260609390931b6bffffffffffffffffffffffff191683820152605480840192909252805180840390920182526074909201909152805191012090565b60008060006111ab8585611442565b909250905060008160048111156111c4576111c4611ae7565b1480156111e25750856001600160a01b0316826001600160a01b0316145b806111f357506111f3868686611487565b9695505050505050565b611205611095565b6000611212848484611153565b60008181526006602052604090205490915060ff166112605760405162461bcd60e51b815260206004820152600a6024820152691b9bc81c995c5d595cdd60b21b604482015260640161035d565b336000908152600560205260409020548411156112bf5760405162461bcd60e51b815260206004820152601760248201527f616d6f756e74203e2072657175657374416d6f756e7473000000000000000000604482015260640161035d565b6000818152600660209081526040808320805460ff191690553383526005909152812080548692906112f2908490611ad4565b9091555050604080518581526020810184905233917f8beac21ec0206d8057c3ea48edd216fd5e5346e0cdedf004fe19773ebed39d62910160405180910390a250505050565b6040516001600160a01b03831660248201526044810182905261136890849063a9059cbb60e01b90606401611116565b505050565b60006113c2826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166115739092919063ffffffff16565b90508051600014806113e35750808060200190518101906113e39190611a99565b6113685760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161035d565b60008082516041036114785760208301516040840151606085015160001a61146c87828585611582565b94509450505050611480565b506000905060025b9250929050565b6000806000856001600160a01b0316631626ba7e60e01b86866040516024016114b1929190611b4d565b60408051601f198184030181529181526020820180516001600160e01b03166001600160e01b03199094169390931790925290516114ef9190611b66565b600060405180830381855afa9150503d806000811461152a576040519150601f19603f3d011682016040523d82523d6000602084013e61152f565b606091505b509150915081801561154357506020815110155b80156111f357508051630b135d3f60e11b906115689083016020908101908401611b82565b149695505050505050565b6060610e568484600085611646565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156115b9575060009050600361163d565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa15801561160d573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166116365760006001925092505061163d565b9150600090505b94509492505050565b6060824710156116a75760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161035d565b600080866001600160a01b031685876040516116c39190611b66565b60006040518083038185875af1925050503d8060008114611700576040519150601f19603f3d011682016040523d82523d6000602084013e611705565b606091505b509150915061171687838387611721565b979650505050505050565b60608315611790578251600003611789576001600160a01b0385163b6117895760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161035d565b5081610e56565b610e5683838151156117a55781518083602001fd5b8060405162461bcd60e51b815260040161035d9190611b9b565b6000602082840312156117d157600080fd5b5035919050565b80356001600160a01b03811681146117ef57600080fd5b919050565b60006020828403121561180657600080fd5b61180f826117d8565b9392505050565b60008083601f84011261182857600080fd5b50813567ffffffffffffffff81111561184057600080fd5b6020830191508360208260051b850101111561148057600080fd5b6000806000806000806000806080898b03121561187757600080fd5b883567ffffffffffffffff8082111561188f57600080fd5b61189b8c838d01611816565b909a50985060208b01359150808211156118b457600080fd5b6118c08c838d01611816565b909850965060408b01359150808211156118d957600080fd5b6118e58c838d01611816565b909650945060608b01359150808211156118fe57600080fd5b5061190b8b828c01611816565b999c989b5096995094979396929594505050565b6000806040838503121561193257600080fd5b82359150611942602084016117d8565b90509250929050565b60008060008060006080868803121561196357600080fd5b853594506020860135935060408601359250606086013567ffffffffffffffff8082111561199057600080fd5b818801915088601f8301126119a457600080fd5b8135818111156119b357600080fd5b8960208285010111156119c557600080fd5b9699959850939650602001949392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052603260045260246000fd5b6000808335601e19843603018112611a3a57600080fd5b83018035915067ffffffffffffffff821115611a5557600080fd5b60200191503681900382131561148057600080fd5b634e487b7160e01b600052601160045260246000fd5b600060018201611a9257611a92611a6a565b5060010190565b600060208284031215611aab57600080fd5b8151801515811461180f57600080fd5b80820180821115611ace57611ace611a6a565b92915050565b81810381811115611ace57611ace611a6a565b634e487b7160e01b600052602160045260246000fd5b60005b83811015611b18578181015183820152602001611b00565b50506000910152565b60008151808452611b39816020860160208601611afd565b601f01601f19169290920160200192915050565b828152604060208201526000610e566040830184611b21565b60008251611b78818460208701611afd565b9190910192915050565b600060208284031215611b9457600080fd5b5051919050565b60208152600061180f6020830184611b2156fea164736f6c6343000813000a
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000aef67478a5595fc220d43338b8674dc50c6de54f00000000000000000000000009d6f0f5a21f5be4f59e209747e2d07f50bc694c000000000000000000000000bf72e7c502bf088b0ff674c67d569da1304faab80000000000000000000000005ea4de24d668085d37c423e1d4eef5acc76daaaa0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000034bc00
-----Decoded View---------------
Arg [0] : _admin (address): 0xAEF67478a5595Fc220d43338b8674dC50c6DE54f
Arg [1] : _nftfi (address): 0x09D6F0F5A21f5BE4f59e209747E2d07F50BC694C
Arg [2] : _distributorRegistry (address): 0xBf72E7c502Bf088B0Ff674c67d569Da1304faaB8
Arg [3] : _tokenUtilityAccounting (address): 0x5ea4De24d668085d37C423E1D4eEf5ACc76DaaAa
Arg [4] : _protocolSignerAddress (address): 0x0000000000000000000000000000000000000000
Arg [5] : _cooldown (uint256): 3456000
-----Encoded View---------------
6 Constructor Arguments found :
Arg [0] : 000000000000000000000000aef67478a5595fc220d43338b8674dc50c6de54f
Arg [1] : 00000000000000000000000009d6f0f5a21f5be4f59e209747e2d07f50bc694c
Arg [2] : 000000000000000000000000bf72e7c502bf088b0ff674c67d569da1304faab8
Arg [3] : 0000000000000000000000005ea4de24d668085d37c423e1d4eef5acc76daaaa
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [5] : 000000000000000000000000000000000000000000000000000000000034bc00
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|---|---|---|---|---|
ETH | 100.00% | $0.005816 | 40,239,958 | $234,051.29 |
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.