// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)pragmasolidity ^0.8.0;/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/interfaceIERC20{
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/eventTransfer(addressindexedfrom, addressindexed 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.
*/eventApproval(addressindexed owner, addressindexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/functiontotalSupply() externalviewreturns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/functionbalanceOf(address account) externalviewreturns (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.
*/functiontransfer(address to, uint256 amount) externalreturns (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.
*/functionallowance(address owner, address spender) externalviewreturns (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.
*/functionapprove(address spender, uint256 amount) externalreturns (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.
*/functiontransferFrom(addressfrom,
address to,
uint256 amount
) externalreturns (bool);
}
Contract Source Code
File 4 of 5: MerkleProofLib.sol
// SPDX-License-Identifier: MITpragmasolidity >=0.8.0;/// @notice Gas optimized merkle proof verification library./// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/MerkleProofLib.sol)/// @author Modified from Solady (https://github.com/Vectorized/solady/blob/main/src/utils/MerkleProofLib.sol)libraryMerkleProofLib{
functionverify(bytes32[] calldata proof,
bytes32 root,
bytes32 leaf
) internalpurereturns (bool isValid) {
/// @solidity memory-safe-assemblyassembly {
if proof.length {
// Left shifting by 5 is like multiplying by 32.let end :=add(proof.offset, shl(5, proof.length))
// Initialize offset to the offset of the proof in calldata.let offset := proof.offset// Iterate over proof elements to compute root hash.// prettier-ignorefor {} 1 {} {
// Slot where the leaf should be put in scratch space. If// leaf > calldataload(offset): slot 32, otherwise: slot 0.let leafSlot :=shl(5, gt(leaf, calldataload(offset)))
// Store elements to hash contiguously in scratch space.// The xor puts calldataload(offset) in whichever slot leaf// is not occupying, so 0 if leafSlot is 32, and 32 otherwise.mstore(leafSlot, leaf)
mstore(xor(leafSlot, 32), calldataload(offset))
// Reuse leaf to store the hash to reduce stack operations.
leaf :=keccak256(0, 64) // Hash both slots of scratch space.
offset :=add(offset, 32) // Shift 1 word per cycle.// prettier-ignoreifiszero(lt(offset, end)) { break }
}
}
isValid :=eq(leaf, root) // The proof is valid if the roots match.
}
}
}
Contract Source Code
File 5 of 5: ProxyOwnable.sol
// SPDX-License-Identifier: MITpragmasolidity >=0.8.4 <0.9.0;import { Errors } from"../library/errors/Errors.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there are two accounts (an owner and a proxy) that can be granted exclusive
* access to specific functions. Only the owner can set the proxy.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This contract enables a pattern whereby another contract can be set as a
* proxy to interact with the inheriting contract with administrative privs.
* It also enables a pattern whereby the contract owner is never used for
* general contract admin actions. It's only used to set privileged accounts,
* while the proxy account operates the contract as the administrator.
*
* This module is used through inheritance. It will make available the modifiers
* `onlyOwner` and `onlyAuthorized`, which can be applied to your functions to
* restrict their use to the owner or the proxy.
*/abstractcontractProxyOwnable{
addresspublic _owner;
addresspublic _proxy;
eventOwnershipTransferred(addressindexed previousOwner, addressindexed newOwner);
constructor() {
_setOwner(msg.sender);
}
/**
* @dev Returns the address of the current owner.
*/functionowner() publicviewvirtualreturns (address) {
return _owner;
}
/**
* @dev Returns the address of the current proxy.
*/functionproxy() publicviewvirtualreturns (address) {
return _proxy;
}
/**
* @dev Throws if called by any account other than the owner.
*/modifieronlyOwner() {
if (owner() !=msg.sender) revert Errors.UserPermissions();
_;
}
/**
* @dev Throws if called by any account other than the proxy or the owner.
*/modifieronlyAuthorized() {
if (
proxy() !=msg.sender&&
owner() !=msg.sender
) revert Errors.UserPermissions();
_;
}
functioncheckAuthorized(address operator) publicviewvirtual{
if (
proxy() != operator &&
owner() != operator
) revert Errors.UserPermissions();
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/functionrenounceOwnership() publicvirtualonlyOwner{
_setOwner(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/functiontransferOwnership(address newOwner) publicvirtualonlyOwner{
if (newOwner ==address(0)) revert Errors.AddressTarget(newOwner);
_setOwner(newOwner);
}
/**
* @dev Sets the proxy for the contract to a new account (`newProxy`).
* Can only be called by the current owner.
*/functionsetProxy(address newProxy) publicvirtualonlyOwner{
_proxy = newProxy;
}
function_setOwner(address newOwner) internal{
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}