Description:
Multi-signature wallet contract requiring multiple confirmations for transaction execution.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"src/StableTokenV1.sol": {
"content": "// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.26;
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import {PausableUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {Blacklistable} from "./libraries/Blacklistable.sol";
import {MintManager} from "./libraries/MintManager.sol";
import {EIP3009} from "./libraries/EIP3009.sol";
import {Utils} from "./libraries/Utils.sol";
/**
* @title StableTokenV1
* @dev Implementation of a stablecoin with minting, burning, blacklisting, and EIP-3009 capabilities.
* This contract is upgradeable using the UUPS pattern and implements ERC20 with permit functionality.
*/
contract StableTokenV1 is
Initializable,
UUPSUpgradeable,
PausableUpgradeable,
Blacklistable,
MintManager,
EIP3009
{
using SafeERC20 for IERC20;
using Utils for bytes;
/// @notice Version of the contract
string private constant _version = "1";
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
}
/**
* @notice Initializes the contract with required parameters
* @dev Sets up roles, token metadata, and initializes inherited contracts
* @param name Name of the token
* @param symbol Symbol of the token
* @param defaultAdmin Address of the default admin
* @param mainMinter Address with permission to manage minters
*/
function initialize(
string calldata name,
string calldata symbol,
address defaultAdmin,
address mainMinter
) public initializer {
assert(defaultAdmin != address(0));
assert(mainMinter != address(0));
__UUPSUpgradeable_init();
__Pausable_init();
__ERC20_init(name, symbol);
__ERC20Permit_init(name);
__AccessControlDefaultAdminRules_init(3 days, defaultAdmin);
_grantRole(MAIN_MINTER_ROLE, mainMinter);
_setRoleAdmin(MINTER_ROLE, MAIN_MINTER_ROLE);
}
/**
* @dev Authorizes an upgrade to a new implementation
* @param newImplementation Address of the new implementation
*/
function _authorizeUpgrade(
address newImplementation
) internal override onlyRole(UPGRADER_ROLE) {}
/**
* @dev Returns the EIP712 name for this contract
* @return The name string
*/
function _EIP712Name()
internal
view
virtual
override
returns (string memory)
{
return name();
}
/**
* @dev Returns the EIP712 version for this contract
* @return The version string
*/
function _EIP712Version()
internal
pure
virtual
override
returns (string memory)
{
return _version;
}
/**
* @notice Returns the version of the contract
* @return The version string
*/
function version() public pure virtual returns (string memory) {
return _version;
}
/**
* @notice Returns the number of decimals used for token amounts
* @return The number of decimals (6)
*/
function decimals() public pure override returns (uint8) {
return 6;
}
/**
* @notice Pauses all token transfers and operations
* @dev Can only be called by an account with PAUSER_ROLE
*/
function pause() public onlyRole(PAUSER_ROLE) {
_pause();
}
/**
* @notice Unpauses token transfers and operations
* @dev Can only be called by an account with PAUSER_ROLE
*/
function unpause() public onlyRole(PAUSER_ROLE) {
_unpause();
}
/**
* @notice Rescues ERC20 tokens sent to this contract by mistake
* @dev Can only be called by an account with RESCUER_ROLE
* @param tokenContract The ERC20 token contract address
* @param to The address to send the tokens to
* @param amount The amount of tokens to rescue
*/
function rescueERC20(
IERC20 tokenContract,
address to,
uint256 amount
) public onlyRole(RESCUER_ROLE) {
tokenContract.safeTransfer(to, amount);
}
/**
* @notice Configures a minter with a specific allowance
* @dev Can only be called by an account with MAIN_MINTER_ROLE when contract is not paused
* @param minter Address to configure as a minter
* @param minterAllowedAmount Amount the minter is allowed to mint
* @return bool True if the operation was successful
*/
function configureMinter(
address minter,
uint256 minterAllowedAmount
) public override whenNotPaused returns (bool) {
return super.configureMinter(minter, minterAllowedAmount);
}
/**
* @notice Updates token balances during transfers.
* @dev Overrides the ERC20 _update function to add blacklist and pause checks.
* @param from The address tokens are transferred from.
* @param to The address tokens are transferred to.
* @param value The amount of tokens to transfer.
*/
function _update(
address from,
address to,
uint256 value
)
internal
virtual
override
whenNotPaused
notBlacklisted(from)
notBlacklisted(to)
{
super._update(from, to, value);
}
/**
* @notice Internal function to set the allowance of tokens that a spender can use from an owner's account
* @dev Overrides the parent contract's _approve function to add pause and blacklist check
* @param owner The address that owns the tokens
* @param spender The address authorized to spend the tokens
* @param value The amount of tokens to allow
* @param emitEvent If true, emits an Approval event
*/
function _approve(
address owner,
address spender,
uint256 value,
bool emitEvent
)
internal
override
whenNotPaused
notBlacklisted(owner)
notBlacklisted(spender)
{
super._approve(owner, spender, value, emitEvent);
}
/**
* @notice Increases the allowance granted to the spender
* @param spender The address authorized to spend
* @param increment The amount to increase the allowance by
* @return True if the operation was successful
*/
function increaseAllowance(
address spender,
uint256 increment
) public returns (bool) {
return approve(spender, allowance(msg.sender, spender) + increment);
}
/**
* @notice Decreases the allowance granted to the spender
* @param spender The address authorized to spend
* @param decrement The amount to decrease the allowance by
* @return True if the operation was successful
*/
function decreaseAllowance(
address spender,
uint256 decrement
) public returns (bool) {
return approve(spender, allowance(msg.sender, spender) - decrement);
}
/**
* @notice Approves spending via EIP-2612 permit with signature as bytes
* @dev Decodes the signature and calls the parent permit function
* @param owner The owner of the tokens
* @param spender The address authorized to spend
* @param value The amount of tokens to allow
* @param deadline The time at which the signature expires
* @param signature The authorization signature as bytes
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
bytes calldata signature
) public {
(bytes32 r, bytes32 s, uint8 v) = signature.decodeRSV();
permit(owner, spender, value, deadline, v, r, s);
}
/**
* @notice Cancels an authorization via signature as bytes (EIP-3009)
* @param authorizer The address that authorized the transfer
* @param nonce The nonce of the authorization to cancel
* @param signature The authorization signature as bytes
*/
function cancelAuthorization(
address authorizer,
bytes32 nonce,
bytes calldata signature
) public override whenNotPaused {
super.cancelAuthorization(authorizer, nonce, signature);
}
}
"
},
"dependencies/@openzeppelin-contracts-upgradeable-5.2.0/proxy/utils/Initializable.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.20;
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```solidity
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
*
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Storage of the initializable contract.
*
* It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions
* when using with upgradeable contracts.
*
* @custom:storage-location erc7201:openzeppelin.storage.Initializable
*/
struct InitializableStorage {
/**
* @dev Indicates that the contract has been initialized.
*/
uint64 _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool _initializing;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;
/**
* @dev The contract is already initialized.
*/
error InvalidInitialization();
/**
* @dev The contract is not initializing.
*/
error NotInitializing();
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint64 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any
* number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
* production.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
// Cache values to avoid duplicated sloads
bool isTopLevelCall = !$._initializing;
uint64 initialized = $._initialized;
// Allowed calls:
// - initialSetup: the contract is not in the initializing state and no previous version was
// initialized
// - construction: the contract is initialized at version 1 (no reininitialization) and the
// current contract is just being deployed
bool initialSetup = initialized == 0 && isTopLevelCall;
bool construction = initialized == 1 && address(this).code.length == 0;
if (!initialSetup && !construction) {
revert InvalidInitialization();
}
$._initialized = 1;
if (isTopLevelCall) {
$._initializing = true;
}
_;
if (isTopLevelCall) {
$._initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint64 version) {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing || $._initialized >= version) {
revert InvalidInitialization();
}
$._initialized = version;
$._initializing = true;
_;
$._initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
_checkInitializing();
_;
}
/**
* @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
*/
function _checkInitializing() internal view virtual {
if (!_isInitializing()) {
revert NotInitializing();
}
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing) {
revert InvalidInitialization();
}
if ($._initialized != type(uint64).max) {
$._initialized = type(uint64).max;
emit Initialized(type(uint64).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint64) {
return _getInitializableStorage()._initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _getInitializableStorage()._initializing;
}
/**
* @dev Returns a pointer to the storage namespace.
*/
// solhint-disable-next-line var-name-mixedcase
function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
assembly {
$.slot := INITIALIZABLE_STORAGE
}
}
}
"
},
"dependencies/@openzeppelin-contracts-upgradeable-5.2.0/proxy/utils/UUPSUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.2.0) (proxy/utils/UUPSUpgradeable.sol)
pragma solidity ^0.8.22;
import {IERC1822Proxiable} from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol";
import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol";
import {Initializable} from "./Initializable.sol";
/**
* @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
* {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
*
* A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
* reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
* `UUPSUpgradeable` with a custom implementation of upgrades.
*
* The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
*/
abstract contract UUPSUpgradeable is Initializable, IERC1822Proxiable {
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
address private immutable __self = address(this);
/**
* @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgradeTo(address)`
* and `upgradeToAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called,
* while `upgradeToAndCall` will invoke the `receive` function if the second argument is the empty byte string.
* If the getter returns `"5.0.0"`, only `upgradeToAndCall(address,bytes)` is present, and the second argument must
* be the empty byte string if no function should be called, making it impossible to invoke the `receive` function
* during an upgrade.
*/
string public constant UPGRADE_INTERFACE_VERSION = "5.0.0";
/**
* @dev The call is from an unauthorized context.
*/
error UUPSUnauthorizedCallContext();
/**
* @dev The storage `slot` is unsupported as a UUID.
*/
error UUPSUnsupportedProxiableUUID(bytes32 slot);
/**
* @dev Check that the execution is being performed through a delegatecall call and that the execution context is
* a proxy contract with an implementation (as defined in ERC-1967) pointing to self. This should only be the case
* for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
* function through ERC-1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
* fail.
*/
modifier onlyProxy() {
_checkProxy();
_;
}
/**
* @dev Check that the execution is not being performed through a delegate call. This allows a function to be
* callable on the implementing contract but not through proxies.
*/
modifier notDelegated() {
_checkNotDelegated();
_;
}
function __UUPSUpgradeable_init() internal onlyInitializing {
}
function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
}
/**
* @dev Implementation of the ERC-1822 {proxiableUUID} function. This returns the storage slot used by the
* implementation. It is used to validate the implementation's compatibility when performing an upgrade.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
*/
function proxiableUUID() external view virtual notDelegated returns (bytes32) {
return ERC1967Utils.IMPLEMENTATION_SLOT;
}
/**
* @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
* encoded in `data`.
*
* Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*
* @custom:oz-upgrades-unsafe-allow-reachable delegatecall
*/
function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallUUPS(newImplementation, data);
}
/**
* @dev Reverts if the execution is not performed via delegatecall or the execution
* context is not of a proxy with an ERC-1967 compliant implementation pointing to self.
* See {_onlyProxy}.
*/
function _checkProxy() internal view virtual {
if (
address(this) == __self || // Must be called through delegatecall
ERC1967Utils.getImplementation() != __self // Must be called through an active proxy
) {
revert UUPSUnauthorizedCallContext();
}
}
/**
* @dev Reverts if the execution is performed via delegatecall.
* See {notDelegated}.
*/
function _checkNotDelegated() internal view virtual {
if (address(this) != __self) {
// Must not be called through delegatecall
revert UUPSUnauthorizedCallContext();
}
}
/**
* @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
* {upgradeToAndCall}.
*
* Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
*
* ```solidity
* function _authorizeUpgrade(address) internal onlyOwner {}
* ```
*/
function _authorizeUpgrade(address newImplementation) internal virtual;
/**
* @dev Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call.
*
* As a security check, {proxiableUUID} is invoked in the new implementation, and the return value
* is expected to be the implementation slot in ERC-1967.
*
* Emits an {IERC1967-Upgraded} event.
*/
function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private {
try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
if (slot != ERC1967Utils.IMPLEMENTATION_SLOT) {
revert UUPSUnsupportedProxiableUUID(slot);
}
ERC1967Utils.upgradeToAndCall(newImplementation, data);
} catch {
// The implementation is not UUPS
revert ERC1967Utils.ERC1967InvalidImplementation(newImplementation);
}
}
}
"
},
"dependencies/@openzeppelin-contracts-upgradeable-5.2.0/utils/PausableUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol)
pragma solidity ^0.8.20;
import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.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 PausableUpgradeable is Initializable, ContextUpgradeable {
/// @custom:storage-location erc7201:openzeppelin.storage.Pausable
struct PausableStorage {
bool _paused;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Pausable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant PausableStorageLocation = 0xcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300;
function _getPausableStorage() private pure returns (PausableStorage storage $) {
assembly {
$.slot := PausableStorageLocation
}
}
/**
* @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);
/**
* @dev The operation failed because the contract is paused.
*/
error EnforcedPause();
/**
* @dev The operation failed because the contract is not paused.
*/
error ExpectedPause();
/**
* @dev Initializes the contract in unpaused state.
*/
function __Pausable_init() internal onlyInitializing {
__Pausable_init_unchained();
}
function __Pausable_init_unchained() internal onlyInitializing {
PausableStorage storage $ = _getPausableStorage();
$._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) {
PausableStorage storage $ = _getPausableStorage();
return $._paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
if (paused()) {
revert EnforcedPause();
}
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
if (!paused()) {
revert ExpectedPause();
}
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
PausableStorage storage $ = _getPausableStorage();
$._paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
PausableStorage storage $ = _getPausableStorage();
$._paused = false;
emit Unpaused(_msgSender());
}
}
"
},
"dependencies/@openzeppelin-contracts-5.2.0/token/ERC20/IERC20.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
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 value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` 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 value) external returns (bool);
}
"
},
"dependencies/@openzeppelin-contracts-5.2.0/token/ERC20/utils/SafeERC20.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.2.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC-20 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 {
/**
* @dev An operation with an ERC-20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @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.encodeCall(token.transfer, (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.encodeCall(token.transferFrom, (from, to, 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.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @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.
*
* NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
* only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
* set here.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
safeTransfer(token, to, value);
} else if (!token.transferAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
* has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferFromAndCallRelaxed(
IERC1363 token,
address from,
address to,
uint256 value,
bytes memory data
) internal {
if (to.code.length == 0) {
safeTransferFrom(token, from, to, value);
} else if (!token.transferFromAndCall(from, to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
* Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
* once without retrying, and relies on the returned value to be true.
*
* Reverts if the returned value is other than `true`.
*/
function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
forceApprove(token, to, value);
} else if (!token.approveAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @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 {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
// bubble errors
if iszero(success) {
let ptr := mload(0x40)
returndatacopy(ptr, 0, returndatasize())
revert(ptr, returndatasize())
}
returnSize := returndatasize()
returnValue := mload(0)
}
if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @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 silently catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
bool success;
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
returnSize := returndatasize()
returnValue := mload(0)
}
return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
}
}
"
},
"src/libraries/Blacklistable.sol": {
"content": "// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.26;
import {RoleManager} from "./RoleManager.sol";
/**
* @title Blacklistable
* @dev Contract module that allows for blacklisting of addresses.
* Addresses in the blacklist are restricted from certain operations.
* Only accounts with BLACKLISTER_ROLE can add or remove addresses from the blacklist.
*/
abstract contract Blacklistable is RoleManager {
/**
* @dev Mapping to track blacklisted addresses.
* If an address maps to true, it is blacklisted.
*/
mapping(address => bool) private _isBlacklisted;
/**
* @dev Emitted when an account is added to the blacklist.
* @param account The address that was blacklisted.
*/
event Blacklisted(address indexed account);
/**
* @dev Emitted when an account is removed from the blacklist.
* @param account The address that was removed from the blacklist.
*/
event UnBlacklisted(address indexed account);
/**
* @dev Error thrown when an operation is attempted with a blacklisted address.
* @param account The blacklisted address.
*/
error InBlacklist(address account);
/**
* @dev Modifier to check if an account is blacklisted.
* Reverts if the account is blacklisted.
* @param account The address to check.
*/
modifier notBlacklisted(address account) {
if (_isBlacklisted[account]) revert InBlacklist(account);
_;
}
/**
* @notice Checks if account is blacklisted.
* @param account The address to check.
* @return True if the account is blacklisted, false if the account is not blacklisted.
*/
function isBlacklisted(address account) public view returns (bool) {
return _isBlacklisted[account];
}
/**
* @notice Adds account to blacklist.
* @param account The address to blacklist.
* @dev Only callable by accounts with BLACKLISTER_ROLE.
*/
function blacklist(address account) public onlyRole(BLACKLISTER_ROLE) {
_isBlacklisted[account] = true;
emit Blacklisted(account);
}
/**
* @notice Removes account from blacklist.
* @param account The address to remove from the blacklist.
* @dev Only callable by accounts with BLACKLISTER_ROLE.
*/
function unBlacklist(address account) public onlyRole(BLACKLISTER_ROLE) {
_isBlacklisted[account] = false;
emit UnBlacklisted(account);
}
}
"
},
"src/libraries/MintManager.sol": {
"content": "// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.26;
import {ERC20PermitUpgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20PermitUpgradeable.sol";
import {RoleManager} from "./RoleManager.sol";
import {IMintManager} from "../interfaces/IMintManager.sol";
/**
* @title MintManager
* @dev Contract for managing token minting and burning.
* The MintManager contract inherits from ERC20PermitUpgradeable, RoleManager, and IMintManager.
* It provides methods for managing minters, minting new tokens, and burning tokens.
* The contract also provides methods for checking if an account has minter privileges, retrieving
* the amount a minter is allowed to mint, configuring a minter with a specific allowance, and removing
* a minter from the system.
*/
abstract contract MintManager is
ERC20PermitUpgradeable,
RoleManager,
IMintManager
{
/// @dev Mapping of minter addresses to their allowed minting amounts
mapping(address => uint256) private _minterAllowed;
/**
* @notice Checks if an account has minter privileges
* @param account Address to check for minter role
* @return bool True if the account has minter role, false otherwise
*/
function isMinter(address account) public view returns (bool) {
return hasRole(MINTER_ROLE, account);
}
/**
* @notice Returns the amount a minter is allowed to mint
* @param minter Address of the minter to check
* @return uint256 The amount the minter is allowed to mint
*/
function minterAllowance(address minter) public view returns (uint256) {
return _minterAllowed[minter];
}
/**
* @notice Configures a minter with a specific allowance
* @dev Can only be called by an account with MAIN_MINTER_ROLE
* @param minter Address to configure as a minter
* @param minterAllowedAmount Amount the minter is allowed to mint
* @return bool True if the operation was successful
*/
function configureMinter(
address minter,
uint256 minterAllowedAmount
) public virtual onlyRole(MAIN_MINTER_ROLE) returns (bool) {
assert(minter != address(0));
_grantRole(MINTER_ROLE, minter);
_minterAllowed[minter] = minterAllowedAmount;
emit MinterConfigured(minter, minterAllowedAmount);
return true;
}
/**
* @notice Removes a minter from the system
* @dev Can only be called by an account with MAIN_MINTER_ROLE
* @param minter Address of the minter to remove
* @return bool True if the operation was successful
*/
function removeMinter(
address minter
) public virtual onlyRole(MAIN_MINTER_ROLE) returns (bool) {
_revokeRole(MINTER_ROLE, minter);
_minterAllowed[minter] = 0;
emit MinterRemoved(minter);
return true;
}
/**
* @notice Mints new tokens to the specified address
* @dev Can only be called by an account with MINTER_ROLE
* @param to The address to mint tokens to
* @param amount The amount of tokens to mint
*/
function mint(address to, uint256 amount) public onlyRole(MINTER_ROLE) {
if (amount == 0) {
revert InvalidAmount(0);
}
_mint(to, amount);
_minterAllowed[msg.sender] -= amount;
emit Mint(msg.sender, to, amount);
}
/**
* @notice Burns tokens from the caller's account
* @dev Can only be called by an account with MINTER_ROLE
* @param amount The amount of tokens to burn
*/
function burn(uint256 amount) public onlyRole(MINTER_ROLE) {
if (amount == 0) {
revert InvalidAmount(0);
}
_burn(msg.sender, amount);
emit Burn(msg.sender, amount);
}
}
"
},
"src/libraries/EIP3009.sol": {
"content": "// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.26;
import {ERC20PermitUpgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20PermitUpgradeable.sol";
import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import {Utils} from "./Utils.sol";
/**
* @title EIP-3009
* @notice Provides internal implementation for gas-abstracted transfers according to EIP-3009 standard
* @dev Contracts that inherit from this must wrap these functions with publicly
* accessible methods, optionally adding modifiers where necessary.
* This implementation allows for meta-transactions where users can sign transfer
* authorizations off-chain and third parties can execute them on-chain.
*/
abstract contract EIP3009 is ERC20PermitUpgradeable {
using Utils for bytes;
bytes32 public constant TRANSFER_WITH_AUTHORIZATION_TYPEHASH =
keccak256(
"TransferWithAuthorization(address from,address to,uint256 value,uint256 validAfter,uint256 validBefore,bytes32 nonce)"
);
bytes32 public constant RECEIVE_WITH_AUTHORIZATION_TYPEHASH =
keccak256(
"ReceiveWithAuthorization(address from,address to,uint256 value,uint256 validAfter,uint256 validBefore,bytes32 nonce)"
);
bytes32 public constant CANCEL_AUTHORIZATION_TYPEHASH =
keccak256("CancelAuthorization(address authorizer,bytes32 nonce)");
/**
* @dev Maps authorizer address to nonce to usage state
* authorizer address => nonce => bool (true if nonce is used)
*/
mapping(address => mapping(bytes32 => bool)) private _authorizationStates;
/**
* @dev Emitted when an authorization is used
* @param authorizer The address of the authorizer
* @param nonce The nonce of the used authorization
*/
event AuthorizationUsed(address indexed authorizer, bytes32 indexed nonce);
/**
* @dev Emitted when an authorization is canceled
* @param authorizer The address of the authorizer
* @param nonce The nonce of the canceled authorization
*/
event AuthorizationCanceled(
address indexed authorizer,
bytes32 indexed nonce
);
/**
* @dev Error thrown when the caller is not the specified payee
* @param caller The address of the caller
*/
error CallerNotPayee(address caller);
/**
* @dev Error thrown when the signature verification fails
*/
error InvalidSignature();
/**
* @dev Error thrown when the authorization is invalid (already used or canceled)
*/
error AuthorizationInvalid();
/**
* @dev Error thrown when the authorization is not yet valid (current time < validAfter)
* @param start The timestamp after which the authorization becomes valid
*/
error AuthorizationNotYetValid(uint256 start);
/**
* @dev Error thrown when the authorization has expired (current time > validBefore)
* @param expired The timestamp before which the authorization was valid
*/
error AuthorizationExpired(uint256 expired);
/**
* @notice Returns the state of an authorization
* @dev Nonces are randomly generated 32-byte data unique to the
* authorizer's address. Returns true if the nonce has been used or canceled.
* @param authorizer Authorizer's address
* @param nonce Nonce of the authorization
* @return True if the nonce is used or canceled, false otherwise
*/
function authorizationState(
address authorizer,
bytes32 nonce
) public view returns (bool) {
return _authorizationStates[authorizer][nonce];
}
/**
* @notice Execute a transfer with a signed authorization
* @dev This function accepts the v, r, s components of the signature separately
* EOA wallet signatures should be packed in the order of r, s, v.
* @param from Payer's address (Authorizer)
* @param to Payee's address
* @param value Amount to be transferred
* @param validAfter The time after which this is valid (unix time)
* @param validBefore The time before which this is valid (unix time)
* @param nonce Unique nonce to prevent replay attacks
* @param signature Signature byte array produced by an EOA wallet
*/
function transferWithAuthorization(
address from,
address to,
uint256 value,
uint256 validAfter,
uint256 validBefore,
bytes32 nonce,
bytes calldata signature
) public virtual {
(bytes32 r, bytes32 s, uint8 v) = signature.decodeRSV();
transferWithAuthorization(
from,
to,
value,
validAfter,
validBefore,
nonce,
v,
r,
s
);
}
/**
* @notice Execute a transfer with a signed authorization
* @dev This function accepts a packed signature byte array
* @param from Payer's address (Authorizer)
* @param to Payee's address
* @param value Amount to be transferred
* @param validAfter The time after which this is valid (unix time)
* @param validBefore The time before which this is valid (unix time)
* @param nonce Unique nonce to prevent replay attacks
* @param v v of the signature
* @param r r of the signature
* @param s s of the signature
*/
function transferWithAuthorization(
address from,
address to,
uint256 value,
uint256 validAfter,
uint256 validBefore,
bytes32 nonce,
uint8 v,
bytes32 r,
bytes32 s
) public virtual {
_requireValidAuthorization(from, nonce, validAfter, validBefore);
_requireValidSignature(
from,
keccak256(
abi.encode(
TRANSFER_WITH_AUTHORIZATION_TYPEHASH,
from,
to,
value,
validAfter,
validBefore,
nonce
)
),
v,
r,
s
);
_markAuthorizationAsUsed(from, nonce);
_transfer(from, to, value);
}
/**
* @notice Receive a transfer with a signed authorization from the payer
* @dev This function accepts the v, r, s components of the signature separately
* This has an additional check to ensure that the payee's address
* matches the caller of this function to prevent front-running attacks.
* EOA wallet signatures should be packed in the order of r, s, v.
* @param from Payer's address (Authorizer)
* @param to Payee's address
* @param value Amount to be transferred
* @param validAfter The time after which this is valid (unix time)
* @param validBefore The time before which this is valid (unix time)
* @param nonce Unique nonce to prevent replay attacks
* @param signature Signature byte array produced by an EOA wallet
*/
function receiveWithAuthorization(
address from,
address to,
uint256 value,
uint256 validAfter,
uint256 validBefore,
bytes32 nonce,
bytes calldata signature
) public virtual {
(bytes32 r, bytes32 s, uint8 v) = signature.decodeRSV();
receiveWithAuthorization(
from,
to,
value,
validAfter,
validBefore,
nonce,
v,
r,
s
);
}
/**
* @notice Receive a transfer with a signed authorization from the payer
* @dev This function accepts a packed signature byte array
* This has an additional check to ensure that the payee's address
* matches the caller of this function to prevent front-running attacks.
* @param from Payer's address (Authorizer)
* @param to Payee's address
* @param value Amount to be transferred
* @param validAfter The time after which this is valid (unix time)
* @param validBefore The time before which this is valid (unix time)
* @param nonce Unique nonce to prevent replay attacks
* @param v v of the signature
* @param r r of the signature
* @param s s of the signature
*/
function receiveWithAuthorization(
address from,
address to,
uint256 value,
uint256 validAfter,
uint256 validBefore,
bytes32 nonce,
uint8 v,
bytes32 r,
bytes32 s
) public virtual {
if (to != msg.sender) revert CallerNotPayee(msg.sender);
_requireValidAuthorization(from, nonce, validAfter, validBefore);
_requireValidSignature(
from,
keccak256(
abi.encode(
RECEIVE_WITH_AUTHORIZATION_TYPEHASH,
from,
to,
value,
validAfter,
validBefore,
nonce
)
),
v,
r,
s
);
_markAuthorizationAsUsed(from, nonce);
_transfer(from, to, value);
}
/**
* @notice Attempt to cancel an authorization
* @dev This function accepts the v, r, s components of the signature separately
* EOA wallet signatures should be packed in the order of r, s, v.
* @param authorizer Authorizer's address
* @param nonce Nonce of the authorization to cancel
* @param signature Signature byte array produced by an EOA wallet
*/
function cancelAuthorization(
address authorizer,
bytes32 nonce,
bytes calldata signature
) public virtual {
(bytes32 r, bytes32 s, uint8 v) = signature.decodeRSV();
cancelAuthorization(authorizer, nonce, v, r, s);
}
/**
* @notice Attempt to cancel an authorization
* @dev This function accepts a packed signature byte array
* @param authorizer Authorizer's address
* @param nonce Nonce of the authorization to cancel
* @param v v of the signature
* @param r r of the signature
* @param s s of the signature
*/
function cancelAuthorization(
address authorizer,
bytes32 nonce,
uint8 v,
bytes32 r,
bytes32 s
) public virtual {
_requireUnusedAuthorization(authorizer, nonce);
_requireValidSignature(
authorizer,
keccak256(
abi.encode(CANCEL_AUTHORIZATION_TYPEHASH, authorizer, nonce)
),
v,
r,
s
);
_authorizationStates[authorizer][nonce] = true;
emit AuthorizationCanceled(authorizer, nonce);
}
/**
* @notice Validates signature against input data struct
* @dev Uses OpenZeppelin's ECDSA to verify the signature,
* which supports EOA signatures
* @param signer Signer's address
* @param structHash Hash of encoded data struct
* @param v v of the signature
* @param r r of the signature
* @param s s of the signature
*/
function _requireValidSignature(
address signer,
bytes32 structHash,
uint8 v,
bytes32 r,
bytes32 s
) private view {
if (signer != ECDSA.recover(_hashTypedDataV4(structHash), v, r, s)) {
revert InvalidSignature();
}
}
/**
* @notice Check that an authorization is unused
* @dev Reverts if the authorization has already been used or canceled
* @param authorizer Authorizer's address
* @param nonce Nonce of the authorization
*/
function _requireUnusedAuthorization(
address authorizer,
bytes32 nonce
) private view {
if (_authorizationStates[authorizer][nonce]) {
revert AuthorizationInvalid();
}
}
/**
* @notice Check that authorization is valid
* @dev Verifies time-based validity and that the authorization hasn't been used
* @param authorizer Authorizer's address
* @param nonce Nonce of the authorization
* @param validAfter The time after which this is valid (unix time)
* @param validBefore The time before which this is valid (unix time)
*/
function _requireValidAuthorization(
address authorizer,
bytes32 nonce,
uint256 validAfter,
uint256 validBefore
) private view {
if (block.timestamp <= validAfter) {
revert AuthorizationNotYetValid(validAfter);
}
if (block.timestamp >= validBefore) {
revert AuthorizationExpired(validBefore);
}
_requireUnusedAuthorization(authorizer, nonce);
}
/**
* @notice Mark an authorization as used
* @dev Updates the authorization state and emits an event
* @param authorizer Authorizer's address
* @param nonce Nonce of the authorization
*/
function _markAuthorizationAsUsed(
address authorizer,
bytes32 nonce
) private {
_authorizationStates[authorizer][nonce] = true;
emit AuthorizationUsed(authorizer, nonce);
}
}
"
},
"src/libraries/Utils.sol": {
"content": "// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.26;
/**
* @title Utils
* @dev Library containing utility functions for the stablecoin contract
*/
library Utils {
/// @notice Thrown when the passed in signature is not a valid length
error InvalidSignatureLength();
/**
* @dev Mask used to clear the upper bit of the 's' value in EIP-2098 compact signatures
*/
bytes32 private constant UPPER_BIT_MASK = (
0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
);
/**
* @notice Decodes a signature into its r, s, v components
* @dev Supports standard 65-byte signatures
* @param signature The signature bytes to decode
* @return r The r component of the signature
* @return s The s component of the signature
* @return v The recovery id (v) component of the signature
*/
function decodeRSV(
bytes calldata signature
) internal pure returns (bytes32 r, bytes32 s, uint8 v) {
if (signature.length == 65) {
// Standard signature format
(r, s) = abi.decode(signature, (bytes32, bytes32));
v = uint8(signature[64]);
} else {
revert InvalidSignatureLength();
}
}
}
"
},
"dependencies/@openzeppelin-contracts-5.2.0/interfaces/draft-IERC1822.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC1822.sol)
pragma solidity ^0.8.20;
/**
* @dev ERC-1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
* proxy whose upgrades are fully controlled by the current implementation.
*/
interface IERC1822Proxiable {
/**
* @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
* address.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy.
*/
function proxiableUUID() external view returns (bytes32);
}
"
},
"dependencies/@openzeppelin-contracts-5.2.0/proxy/ERC1967/ERC1967Utils.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.2.0) (proxy/ERC1967/ERC1967Utils.sol)
pragma solidity ^0.8.22;
import {IBeacon} from "../beacon/IBeacon.sol";
import {IERC1967} from "../../interfaces/IERC1967.sol";
import {Address} from "../../utils/Address.sol";
import {StorageSlot} from "../../utils/StorageSlot.sol";
/**
* @dev This library provides getters and event emitting update functions for
* https://eips.ethereum.org/EIPS/eip-1967[ERC-1967] slots.
*/
library ERC1967Utils {
/**
* @dev Storage slot with
Submitted on: 2025-10-31 13:06:10
Comments
Log in to comment.
No comments yet.