IMinterV0
Inherits: EInvalidAddress, EInvalidAmount
Title: IMinterV0
Interface for the MinterV0 contract
Defines structs, enums, events, errors, and public functions for apxUSD minting
Functions
hashOrder
Returns the EIP-712 typed hash for an order
function hashOrder(Order calldata order) external view returns (bytes32);
Parameters
| Name | Type | Description |
|---|---|---|
order | Order | The mint order to hash |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bytes32 | The EIP-712 typed hash |
validateOrder
Validates an order without executing it (reverts if invalid)
function validateOrder(Order calldata order, bytes calldata signature) external view;
Parameters
| Name | Type | Description |
|---|---|---|
order | Order | The mint order to validate |
signature | bytes | The beneficiary's signature over the order |
requestMint
Requests a mint by validating the order and scheduling with AccessManager
function requestMint(Order calldata order, bytes calldata signature) external returns (bytes32 operationId);
Parameters
| Name | Type | Description |
|---|---|---|
order | Order | The mint order |
signature | bytes | The beneficiary's signature over the order |
Returns
| Name | Type | Description |
|---|---|---|
operationId | bytes32 | The unique identifier for this scheduled operation |
executeMint
Executes a scheduled mint operation via AccessManager
function executeMint(bytes32 operationId) external;
Parameters
| Name | Type | Description |
|---|---|---|
operationId | bytes32 | The unique identifier of the scheduled operation |
cancelMint
Cancels a scheduled mint operation
function cancelMint(bytes32 operationId) external;
Parameters
| Name | Type | Description |
|---|---|---|
operationId | bytes32 | The unique identifier of the scheduled operation |
setMaxMintAmount
Updates the maximum mint amount
function setMaxMintAmount(uint208 newMaxMintAmount) external;
Parameters
| Name | Type | Description |
|---|---|---|
newMaxMintAmount | uint208 | New maximum amount for a single mint order |
setRateLimit
Updates the rate limit configuration
function setRateLimit(uint256 newAmount, uint48 newPeriod) external;
Parameters
| Name | Type | Description |
|---|---|---|
newAmount | uint256 | New maximum amount that can be minted within the rate limit period |
newPeriod | uint48 | New duration of the rate limit period in seconds |
cleanMintHistory
Manually cleans up to n expired mint records from the history queue
function cleanMintHistory(uint32 n) external returns (uint32 cleaned);
Parameters
| Name | Type | Description |
|---|---|---|
n | uint32 | Maximum number of records to attempt cleaning |
Returns
| Name | Type | Description |
|---|---|---|
cleaned | uint32 | Number of records actually removed |
nonce
Returns the current nonce for a beneficiary
function nonce(address beneficiary) external view returns (uint48);
Parameters
| Name | Type | Description |
|---|---|---|
beneficiary | address | Address to query nonce for |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint48 | Current nonce value |
pendingOrder
Returns the details of a pending order
function pendingOrder(bytes32 operationId) external view returns (Order memory);
Parameters
| Name | Type | Description |
|---|---|---|
operationId | bytes32 | The unique identifier of the scheduled operation |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Order | order The pending order details |
mintStatus
Returns the status of a mint operation
function mintStatus(bytes32 operationId) external view returns (MintStatus);
Parameters
| Name | Type | Description |
|---|---|---|
operationId | bytes32 | The unique identifier of the operation |
Returns
| Name | Type | Description |
|---|---|---|
<none> | MintStatus | status The current status of the operation |
rateLimit
Returns the current rate limit configuration
function rateLimit() external view returns (uint256 amount, uint48 period);
Returns
| Name | Type | Description |
|---|---|---|
amount | uint256 | Maximum amount that can be minted within the rate limit period |
period | uint48 | Duration of the rate limit period in seconds |
maxMintAmount
Returns the current max mint amount
function maxMintAmount() external view returns (uint208);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint208 | Maximum amount that can be minted in a single order |
rateLimitMinted
Returns the total amount minted in the current rate limit period
function rateLimitMinted() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Total amount minted in the current period |
rateLimitAvailable
Returns the amount available to mint without exceeding the rate limit
function rateLimitAvailable() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Amount that can still be minted in the current period |
Events
MintRequested
Emitted when a mint is requested
event MintRequested(
bytes32 indexed operationId,
address indexed beneficiary,
uint208 amount,
uint48 nonce,
uint48 notBefore,
uint48 notAfter
);
MintExecuted
Emitted when a mint is executed
event MintExecuted(bytes32 indexed operationId, address indexed beneficiary);
MintCancelled
Emitted when a mint is cancelled
event MintCancelled(bytes32 indexed operationId, address indexed beneficiary, address indexed cancelledBy);
MaxMintAmountUpdated
Emitted when max mint amount is updated
event MaxMintAmountUpdated(uint256 oldMax, uint256 newMax);
RateLimitUpdated
Emitted when rate limit is updated
event RateLimitUpdated(uint256 oldAmount, uint48 oldPeriod, uint256 newAmount, uint48 newPeriod);
Errors
InvalidSignature
Error thrown when signature is invalid
TODO: Update to clarify usage (signer != beneficiary)
error InvalidSignature();
InvalidNonce
Error thrown when nonce is invalid
error InvalidNonce(uint48 expected, uint48 provided);
OrderInvalidTimeWindow
Error thrown when order time window is invalid (notAfter < notBefore)
error OrderInvalidTimeWindow();
OrderNotYetValid
Error thrown when current time is before notBefore
error OrderNotYetValid();
OrderExpired
Error thrown when current time is after notAfter
error OrderExpired();
MintAmountTooLarge
Error thrown when mint amount exceeds maximum
error MintAmountTooLarge(uint208 amount, uint208 maxAmount);
OrderNotFound
Error thrown when operation has no stored order
error OrderNotFound();
RateLimitExceeded
Error thrown when mint would exceed period rate limit
error RateLimitExceeded(uint208 requestedAmount, uint256 availableCapacity);
Structs
Order
Struct representing a mint order
Packed into 2 storage slots for gas efficiency
struct Order {
address beneficiary; // 160 bits - slot 0
uint48 notBefore; // 48 bits - slot 0
uint48 notAfter; // 48 bits - slot 0
// ============================================= slot boundary
uint48 nonce; // 48 bits - slot 1
uint208 amount; // 208 bits - slot 1
}
MintRecord
Struct to track mint timestamps and amounts for rate limiting
struct MintRecord {
uint48 timestamp;
uint208 amount; // Packed to fit in single slot with timestamp
}
Enums
MintStatus
Enum representing the status of a mint operation
enum MintStatus {
NotFound, // Order not in storage (never existed, or was executed/cancelled)
Scheduled, // Order pending, before notBefore time or AccessManager delay not passed
Ready, // Order pending and ready to execute (delay passed, within time window)
Expired // Order pending, after notAfter (expired)
}