Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

IMinterV0

Git Source

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

NameTypeDescription
orderOrderThe mint order to hash

Returns

NameTypeDescription
<none>bytes32The 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

NameTypeDescription
orderOrderThe mint order to validate
signaturebytesThe 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

NameTypeDescription
orderOrderThe mint order
signaturebytesThe beneficiary's signature over the order

Returns

NameTypeDescription
operationIdbytes32The unique identifier for this scheduled operation

executeMint

Executes a scheduled mint operation via AccessManager

function executeMint(bytes32 operationId) external;

Parameters

NameTypeDescription
operationIdbytes32The unique identifier of the scheduled operation

cancelMint

Cancels a scheduled mint operation

function cancelMint(bytes32 operationId) external;

Parameters

NameTypeDescription
operationIdbytes32The unique identifier of the scheduled operation

setMaxMintAmount

Updates the maximum mint amount

function setMaxMintAmount(uint208 newMaxMintAmount) external;

Parameters

NameTypeDescription
newMaxMintAmountuint208New maximum amount for a single mint order

setRateLimit

Updates the rate limit configuration

function setRateLimit(uint256 newAmount, uint48 newPeriod) external;

Parameters

NameTypeDescription
newAmountuint256New maximum amount that can be minted within the rate limit period
newPerioduint48New 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

NameTypeDescription
nuint32Maximum number of records to attempt cleaning

Returns

NameTypeDescription
cleaneduint32Number of records actually removed

nonce

Returns the current nonce for a beneficiary

function nonce(address beneficiary) external view returns (uint48);

Parameters

NameTypeDescription
beneficiaryaddressAddress to query nonce for

Returns

NameTypeDescription
<none>uint48Current nonce value

pendingOrder

Returns the details of a pending order

function pendingOrder(bytes32 operationId) external view returns (Order memory);

Parameters

NameTypeDescription
operationIdbytes32The unique identifier of the scheduled operation

Returns

NameTypeDescription
<none>Orderorder The pending order details

mintStatus

Returns the status of a mint operation

function mintStatus(bytes32 operationId) external view returns (MintStatus);

Parameters

NameTypeDescription
operationIdbytes32The unique identifier of the operation

Returns

NameTypeDescription
<none>MintStatusstatus The current status of the operation

rateLimit

Returns the current rate limit configuration

function rateLimit() external view returns (uint256 amount, uint48 period);

Returns

NameTypeDescription
amountuint256Maximum amount that can be minted within the rate limit period
perioduint48Duration of the rate limit period in seconds

maxMintAmount

Returns the current max mint amount

function maxMintAmount() external view returns (uint208);

Returns

NameTypeDescription
<none>uint208Maximum 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

NameTypeDescription
<none>uint256Total 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

NameTypeDescription
<none>uint256Amount 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)
}